Announcement

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

    Filter not working for TextItem

    Hi Isomorphic,

    for each element from "valueMap", filter doesn't work.
    When I in filter enter a "key" from the valueMap (in this case "Costas Hummingbird", then it works) but filter should be on "value" from the valueMap(in this case "First Member"))
    When I use "setFilterEditorProperties(new ComboBoxItem())" then it works as expected. (using 6.1p/v11.1p_2018-03-15).
    Can you help me with this?


    Code:
    package com.smartgwt.sample.client;
    
    import java.util.LinkedHashMap;
    import java.util.Map;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS extends VLayout implements EntryPoint {
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            setWidth100();
            setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new MyWindow().show();
                }
            });
            addMember(recreateBtn);
            new MyWindow().show();
            draw();
        }
    
        private class MyWindow extends Window {
            public MyWindow() {
                setWidth(400);
                setHeight(400);
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                SC.logWarn((" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"));
                setTitle("ComboBox filter issue");
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                ListGrid listGrid = new ListGrid() {
                    {
                        setShowFilterEditor(true);
                        setFilterOnKeypress(true);
                        setCanEdit(true);
                        setDataSource(DataSource.get("animals"));
                        final Map<Object, String> valueMap = new LinkedHashMap<Object, String>();
                        valueMap.put("Costas Hummingbird", "First Member");
                        valueMap.put("Freshwater Stingray", "Second Member");
    
                        ListGridField commonNameLGF = new ListGridField("commonName");
                        commonNameLGF.setValueMap(valueMap);
                        commonNameLGF.setEditorProperties(new ComboBoxItem() {
                            {
                                setAddUnknownValues(false);
                                setValueMap(valueMap);
                            }
                        });
                        commonNameLGF.setFilterEditorProperties(new TextItem());
                        setFields(commonNameLGF);
                        fetchData();
                    }
                };
                addItem(listGrid);
            }
        }
    }

    Best regards
    Pavo
    Last edited by pavo123; 27 Mar 2018, 07:22.

    #2
    You've declared this valueMap only in the ListGrid, not in the DataSource, so filter operations that go to the DataSource can't use it. Declare it in the DataSource instead.

    Comment


      #3
      Hi Isomorphic,

      Can you be more precise? It's unclear to me how to do it. How to declare valueMap in the DataSource?

      Best regards
      Pavo

      Comment


        #4
        This is covered in the QuickStart Guide, and also in the documentation for DataSourceField.valueMap.

        Comment


          #5
          Hi pavo123
          as Isomorphic said, you can use a valueMap for this in your datasource. Here a simple example:
          Code:
          <field name="f_type" type="text">
                      <valueMap>
                          <value>INSERT</value>
                          <value>UPDATE</value>
                          <value>REMOVE</value>
                          <value>FETCH</value>
                          <value>LOGIN</value>
                          <value>LOGOUT</value>
                      </valueMap>
                  </field>
          you can also use type="enum"
          Last edited by edulid; 4 Apr 2018, 23:29.

          Comment


            #6
            Hi edulid,
            thank you for your reply.

            My valueMap always has different values.
            It looks like this: valueMap.put("technicalName", i18n.technicalName()), so for each language the value is different. And size of the valueMap is more than 500.
            Maybe I'm wrong but I think that in this way I can't solve the problem.
            And I repeat again, if I use ComboBoxItem instead of TextItem, everything works perfectly.

            Best regards
            Pavo
            Last edited by pavo123; 5 Apr 2018, 02:30.

            Comment


              #7
              Hi pavo123

              since you have more than 500 entries, why don't you create a table containing all entries, and install your SelectItem with this new table? You can install it using yourCombobox.setOptionDataSource(yourComboBoxDatasource);
              Similar as shown here:
              https://www.smartclient.com/smartgwt...e/#combobox_ms

              Comment


                #8
                Hi edulid

                that's a good idea, but my valueMap has already been generated and I wouldn't like to change anything about it.
                If the language of the system is English: then I have: valueMap.get("technicalName") == Technical name
                If the language of the system is German: then I have: valueMap.get("technicalName") == Technischer Name, etc.

                In my test case (first post), if I use

                Code:
                commonNameLGF.setFilterEditorProperties(new ComboBoxItem());
                then it works, but if I use

                Code:
                commonNameLGF.setFilterEditorProperties(new TextItem());
                then it doesn't work.


                If it works for ComboBoxItem, why doesn't work for TextItem?
                I think this is a bug.

                Comment


                  #9
                  ComboBox filtering with a valueMap takes place client-side, for a TextItem, it goes to the server.

                  So again: server-side valueMap or optionDataSource are the ways to correct your code so that filtering is possible.

                  Comment

                  Working...
                  X