Announcement

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

    Listgrid filtering

    Hi,

    I am trying to get the filtering working as in the showcase:

    Code:
    final ListGrid countryGrid = new ListGrid();
    countryGrid.setWidth(500);
    countryGrid.setHeight(300);
    countryGrid.setDataSource(WorldXmlDS.getInstance());
    
    ListGridField countryCodeField = new ListGridField("countryCode", "Code", 50);
    ListGridField nameField = new ListGridField("countryName", "Country");
    ListGridField capitalField = new ListGridField("capital", "Capital");
    ListGridField continentField = new ListGridField("continent", "Continent");
    
    countryGrid.setFields(countryCodeField, nameField, capitalField, continentField);
    
    countryGrid.setAutoFetchData(true);
    countryGrid.setShowFilterEditor(true);
    
    countryGrid.draw();
    filter as in showcase

    With my code:

    Code:
    DataSource countryDS = SampleDataSource.getInstance();
    
    mygrid = new ListGrid();
    mygrid.setWidth100();
    mygrid.setHeight(500);
    mygrid.setAlternateRecordStyles(true);
    mygrid.setShowAllRecords(true);
    mygrid.setAutoFetchData(true);
    mygrid.setDataSource(countryDS);
    mygrid.setShowFilterEditor(true);
    
    mygrid.draw();
    it shows:
    Click image for larger version

Name:	mydemo-filter.PNG
Views:	168
Size:	42.0 KB
ID:	271351

    How does the filter trigger a dropdown with checkboxes and why only on specific columns?

    Is it possible to have an editable dropdown with checkboxes on all columns?

    Regards,

    Jasper

    #2
    Hi jaspersuijker,

    the ListGrid knows from the DataSource that only a few values are possible and therefore shows the SelectItem with multiple:true.

    You posted in the SmartClient forum, but it seems you are using SmartGWT.
    If you want to customize the filter used for a column used in SmartGWT see setFilterEditorProperties() or this sample.

    What would be the goal for your ListGrid? Is it about the name column?
    As of today (13.0p) your options are:
    • SelectItem
    • SelectItem with multiple:true
    • ComboBoxItem (text entry, only one selected entry possible)
    • MultiComboBoxItem (text entry, multiple selected entries possible, does not look very nice in a ListGrid)
    In a future version there will also be MultiPickerItem and SetFilterItem, but these don't have samples, yet.

    Best regards
    Blama

    Comment


      #3
      Hi Blama,

      Thank you for your response. I was not aware there was a difference in forums... :)

      i will have a look at the sample and maybe use the multicomboxoitem

      regards,

      Jasper

      Comment


        #4
        Hi jaspersuijker,

        please see here for Isomorphic's suggestion for to handle this use case. MultiComboBoxItem just does not look nice in a filterRow, as it needs a lot of horizontal space.

        Best regards
        Blama

        Comment


          #5
          Hi,

          I have been looking at the different suggestions and i agree that he MultiComboBoxItem does not look nice.. :)
          I have also looked at the MultiPickerItem, which by the looks of it is exactly what i am looking for.
          Sadly the documentation is lacking and it is hard to figure out why it is not working as expected.
          I have created a demo for myself to see how it works.
          Click image for larger version

Name:	MultiPickerItem.PNG
Views:	172
Size:	13.4 KB
ID:	271380
          What i noticed is that the buttons are only available after i scroll the grid. Is this a bug or an undocumented feature?
          I alos noticed that the development release has something called AI and this is not documented too.
          Is there a way to get more information about the development release, like the new features and when these features will be available in the normal release?

          regards,

          Jasper

          Comment


            #6
            We're not sure what you're using for docs, but if you are using development releases you need to be using the "-latest" URL if looking at docs at SmartClient.com:

            https://smartclient.com/smartclient-...ultiPickerItem

            You should also refresh frequently as docs are added literally daily. Likewise, it's a good idea to grab new builds frequently.

            Please let us know how it's possible to reproduce this problem with the buttons (make sure you are using the latest build to test).

            Comment


              #7
              Hi Isomorphic,

              I am working with SmartGWT and not smartclient...maybe this needs to move to other forum... but.
              Attached the sample that i have extracted from my application.

              I am using SmartGWT/13.1d/LGPL from 2023-11-22.

              There are not newer versions at this moment.

              With this sample my first issue now, is that it does not show the MultipickerItem as filtereditor.

              So let's look at that first... :)

              regards,

              Jasper

              Attached Files

              Comment


                #8
                This post has already been answered here.

                Comment


                  #9
                  Hi Isomorphic,

                  I am able to show the multipicker now, but i still see some things not working.

                  multiPicker.setDeriveUniqueValues(true);
                  does not provide me a list with unique values

                  multiPicker.setSortDirection(SortDirection.ASCENDING);
                  Does not sort the values in the list ascending (and of course setting descending does not work too)

                  In my test case i have 150 rows. When the multipciker shows, the buttons select all and clear are not available. Only when scrolling through the list enables the buttons.

                  Regards,

                  Jasper

                  Comment


                    #10
                    First, make sure you are using the latest development build, and please report your exact build date.

                    Also, it's not clear if your current test case is similar to the one you previously posted, so please clarify that.

                    Both of the APIs you are talking about potentially cause a difference in the request to the server (setDeriveUniqueValues() uses Server Summaries, setSortDirection() sets dsRequest.sortBy(), etc). You should be able to quickly verify this in your Developer Console (RPC Tab). Then, depending on whether you have your own DataSource or are using one of our built-ins, you can see if the data returned is as expected.

                    Note that the final thing you mentioned - Select All / Clear All not being enabled with a partial dataset - this is expected and doc'd. Those features cannot be enabled while also doing data paging.

                    Comment


                      #11
                      Hi,

                      I have tested this with the niglhty build of 14-01-2024.

                      I am using my own datasource and in my example i set the multipicker on the fileds by retrieving the fields from the listgrid:
                      Code:
                                  MultiPickerItem multiPicker = new MultiPickerItem();
                                  multiPicker.setOptionDataSource(dataSource);
                                  multiPicker.setDeriveUniqueValues(true);
                      
                                  /** This should show the picklist in ascending order */
                                  multiPicker.setSortDirection(SortDirection.ASCENDING);
                                  ListGridField[] fields = listgrid.getFields();
                      
                                  for(ListGridField field : fields)
                                  {
                                     field.setFilterEditorProperties(multiPicker);
                                  }
                      My datasource is client only, is that why the sort and unique values are not working?

                      Regarding the select all / clear all buttons, do you say that the multipicker is doing data paging, when filling the list?
                      Why does it do that? from functional perspective, you want to have the select all button avaliable especially when you have a large list, i would think.


                      Comment


                        #12
                        There should be no problem with asking a clientOnly DataSource to do these queries. If you can show the complete test case that reproduces this problem, we can take a look.

                        Regarding the select all / clear all buttons, do you say that the multipicker is doing data paging, when filling the list?
                        Why does it do that? from functional perspective, you want to have the select all button avaliable especially when you have a large list, i would think.
                        It would be nice if we could completely ignore data transfer costs, but if there were 1 million rows, of course, data paging would be required to handle that. So we cannot just assume that we can load all rows, here or in other components.

                        Comment


                          #13
                          Hi,

                          The attached sources is the test case i use.

                          Regards,

                          Jasper

                          Comment


                            #14
                            Hi Jasper
                            There are a few things to discuss here.

                            Firstly - your code applies the MultiPickerItem to the DataSourceField using setFilterEditorProperties, like this:

                            Code:
                            MultiPickerItem multiItem = new MultiPickerItem();
                            multiItem = multiItem.setSortDirection(SortDirection.ASCENDING);
                            multiItem.setAllowExpressions(true);
                            multiItem = multiItem.setDeriveUniqueValues(true);
                            nameField.setFilterEditorProperties(multiItem);
                            In post #7 you mentioned that this wasn't causing the correct editor type to show up at all. This discussion references the related thread here:
                            https://forums.smartclient.com/forum...opment-release

                            Having revisited this, we do see a problem here where the editor type doesn't appear to get picked up when it should.
                            We have a developer looking into why this would be, and determining if there's a framework problem here that we were unaware of.
                            Regardless, you can resolve this by specifying the the form item type explicitly via setType() when you define the item.

                            Secondly - you're using MultiPickerItem here, when you probably want to use SetFilterItem
                            https://smartclient.com/smartgwtee-l...ilterItem.html

                            SetFilterItem is a specialized MultiPickerItem subclass designed explicitly to create 'inSet' and 'notInSet' type filter criteria for display in a target listGrid - exatly what we're doing here.
                            (The MultiPickerItem can be configured to do the same thing but it requires some more configuration to do so - likely not what you want)

                            We have been unable to reproduce any problems with the setDeriveUniqueValues() setting when using a SetFilterItem - it is possible this was a result of using a MultiFilterItem in combination with an explicit valueMap or optionDataSource in a way that wasn't quite appropriate for your usage.

                            The problem with sorting is due to the fact that a MultiPickerItem (or SetFilterItem) needs both a sortField and a sortDirection to perform sorting - a sortDirection alone doesn't cut it.

                            Putting this all together, you should be able to get the filter component you need via something like the folllowing code structure:

                            Code:
                            SetFilterItem multiItem = new SetFilterItem();
                            multiItem.setType("SetFilterItem");
                            multiItem.setSortField("dataName");
                            multiItem.setSortDirection(SortDirection.ASCENDING);
                            // multiItem.setDeriveUniqueValues(true); // note deriveUniqueValues is true by default for SetFilterItems, so no need to set this
                            nameField.setFilterEditorProperties(multiItem);
                            Please give this a try in your application and see if it behaves correctly.
                            If not, or if you have additional questions, please let us know. In this case please also re-share any code that isn't identical to what you shared earlier in this thread, so we can be sure we're looking at the same behavior you're seeing

                            Thanks
                            Isomorphic Software

                            Comment


                              #15
                              Hi,

                              Setting the sortfield makes the sorting work.
                              Also using the SetfilterItem instead of hte MultiPicker seems so resolve my issue with the select all and clear all buttons.

                              Please let me know the outcome of the issue when the editor type doesn't appear to be pciked up.
                              When you are able to resolve this i can change my code.

                              Regards,

                              Jasper

                              Comment

                              Working...
                              X