Announcement

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

    How to sort filtereditor drop-down (FK related) values?

    Hi guys,
    I'm struggling on how sort pick list values on the listgrid filter editor, for a FK field.
    This field points to the parent record for a tree-like structure (hence using the same datasource).
    The problem is that its very difficult to choose a filter value on a unordered list.
    I've been able to sort pick-list values for FilterBuilder (as I explained in another post), as you can see below [ATTACH]2814[/ATTACH]

    The problems stands for the drop-down box on the filter editor
    [ATTACH]2815[/ATTACH]
    As the datasource grows to some dozens of rows that kind of unsorted drop-down becomes soon unusable.
    Any idea on how to sort it?

    Using SmartClient Version: SC_SNAPSHOT-2010-12-31/LGPL Development Only (built 2010-12-31)

    I've attachment some example code.

    Cheers
    Davide
    Attached Files

    #2
    Three weeks passed... is my question too silly or no idea at all?
    Isomorphic?

    Comment


      #3
      Seems like you may not have looked at the docs for ComboBoxItem / PickList?

      Comment


        #4
        Originally posted by Isomorphic
        Seems like you may not have looked at the docs for ComboBoxItem / PickList?
        Sorry Isomorphic, I don't quite follow you.
        My problem seems just related to using a SelectItem as editorType for a grid column's filter editor.
        Honestly, the only documentation I've found in order to obtain sorting on SelectItem is relative to SelectItem.sortField property.
        Is there any other property? SelectItem.pickListProperties seems not so related...
        I mean: I know SelectItem.sortField works properly when directly using a SelectItem, but this time I use it only to pass some settings tot he grid filter editor...
        More specifically: since I need to sort drop-down values on the filter editor, I thought to use a SelectItem in order to force sorting on filter editor for a fk-related field (passing it as the editorType for the relevant grid field, as I did for the FilterBuilder).
        But this time configuring the selectItem through SelectItem.setSortField ('...') seems not enough. I've tried using a ComboBoxItem but nothing changes. I've also tried using the PickListProperties for the SelectItem: no results.

        Follows a slightly adapted excerpt from the test code I previously attached.
        What's wrong with it?

        Code:
        final ListGridField idField = new ListGridField ("id");
        final ListGridField nameField = new ListGridField ("name");
        final ListGridField parentField = new ListGridField ("parent_id");
        parentField.setOptionDataSource (getMainDataSource ());
        parentField.setValueField ("id");
        parentField.setDisplayField ("name");
        
        /*
         * the following block SHOULD sort the drop down values for parent field filter editor, but seems irrelevant
         */
        final SelectItem parentItem = new SelectItem ("parent_id");
        parentItem.setOptionDataSource (getMainDataSource ());
        parentItem.setValueField ("id");
        parentItem.setDisplayField ("name");
        
        parentItem.setSortField ("name");
        parentField.setEditorType (parentItem);
        
        listGrid.setFields (idField, nameField, parentField);
        As I said above, I've not found any other method exposed to obtain drop-down list sorting. If I miss them, could you please give me further details (property name, link or paragraph to read)?

        Cheers
        Davide

        Comment


          #5
          Use setFilterEditorType() to configure the FilterEditor.

          Comment


            #6
            Originally posted by Isomorphic
            Use setFilterEditorType() to configure the FilterEditor.
            It works :-)
            Thanks, Really helped me

            Comment


              #7
              For other people having this challenge:

              It is also possible to re-use the object set to the edit field in grid.

              So it is possible to create 1 SelectItem object with some PickListProperties (ie. a drop down grid), and set this object to both the field and the filtereditor:
              Code:
              SelectItem someSelectItem = new SelectItem();
              // ... set all kinds of properties, like a nested grid or whatever.
              
              
              myListGridField.setEditorType(someSelectItem);
              myListGridField.setFilterEditorType(someSelectItem); //same object passed

              Might sound pretty logical, but I was in doubt if that would work.

              Comment

              Working...
              X