Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Server side auto complete with TextItem

    Hi,
    I want to build a search field with a server side auto complete function. How can I add those values to a TextItem?
    TextItem searchText = new TextItem("keyword", "Keyword");

    I know that I have to implement a KeyPressHandler and then query the server database, but how can I add the received values to the TextItem??
    Suppose I received String[] suggestions = {"Word1", "Word2"}; from the server.
    Now I want to call something like searchText.addSuggestions(suggestions);
    How can I do that?

    Thanks

    #2
    No, you don't have to do any of that - use a ComboBox with an optionDataSource. There are several samples in the Showcase.

    Comment


      #3
      Thanks for the fast reply.
      I've found them: http://www.smartclient.com/smartgwt/showcase/#styled_combobox_category

      However, I don't want a ComboBox, but a TextItem (no arrow on the right). I've seen that the TextItem also has setOptionDataSource() function. Will it display the suggestions the same way as the ComboBox?? Otherwise I'll have to remove the ComboBox's arrow somehow.

      Second question: If I want to display already typed letters in bold (like google does), what is the best way to do this? Modify the datasource on every key stroke and add <b> tags to it?

      Thanks

      Comment


        #4
        If I use a DataSource with a ComboBox it works. However, using the same data source with setOptionDataSource() with a TextEdit fails and no auto complete suggestions get displayed. Did I miss something? Or is there an easy way to make a ComboBox look like a TextEdit (remove the arrow) ?

        Comment


          #5
          setShowPickerIcon(false) to hide the dropdown icon.

          Comment

          Working...
          X