Announcement

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

    Handler for ListGrid filter on keypress

    Is there a way to add a handler to a ListGrid's filter editors when filterOnKeypress is true? I would like to change a label's text when the user enters a something in a filter editor.

    I tried ListGrid.getFilterEditorProperties().addKeyDownHandler but got an exception.

    #2
    To customize the filterEditor for some field you need to call "setFilterEditorProperties()" and pass in a formItem with the desired customizations.

    Alternatively, if you're already filtering on keypress, you could use 'addFilterEditorSubmitHandler()' to react to the user either entering a value (which will automatically perform a filter), or clicking the "filter" button.

    Comment


      #3
      Sorry I forgot to mention I tried ListGrid.addFilterEditorSubmitHandler but it only worked after I pressed enter.

      I'll try the other suggestion though.

      Comment


        #4
        I realized ListGrid.addFilterEditorSubmitHandler did work. However, what I wanted to set in the Label was the total number of items in the ListGrid. I'm using ListGrid.getRecords().length, but the filter did not take effect yet so it still has the old total. Any suggestions on how to set the Label to the new total after filtering?

        Comment


          #5
          Would the listGrid "dataArrived" handler work for you?
          This fires whenever fresh data arrives from the server (and would allow you to check conditions, like data length, and update the Label).
          Note that this method actually fires more often than you need (for example with paging enabled, if the user scrolls unloaded rows into view the handler will fire when the revealed data arrives from the server), but it sounds like it would still work for you.

          Comment


            #6
            Thanks for the suggestion. It worked to show the total.

            I also want to show the number of selected records. I used ListGrid.getSelectedRecords().length to set the contents of a label in the DataArrived handler. However, it's still the same number as before executing the data arrived handler code. For example,

            1. Select 2 records with a list of 2 records (e.g., "t1" and "t2")
            - the label says "2 of 2 selected". That's fine
            2. Type something in the filter editor (e.g., "1") that filters to 1 record
            - the label says "2 of 1 selected" even though only 1 record is selected (because the other selected record has been filtered out)
            3. If I type something that filters to the same record that's not filtered (e.g., "t1"), the label updates to "1 of 1 selected"

            Comment


              #7
              The best way to keep track of the selection is to use the SelectionUpdated event. DataArrived does not fire in all the cases where the selection changes.

              Comment


                #8
                Sorry, I forgot to mention that I already have a SelectionUpdated handler as well. However, it only fires when a selection is updated (as expected). But when the filter changes when there are selections, ListGrid.getSelectedRecords().length is not updated (as described in the scenario mentioned previously).

                Comment


                  #9
                  Hi Kevboy,
                  Just a note to let you know we're going to look into this and respond when we have more information.

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    We've made a change to both 9.1 and 10.0d branches such that when the 'dataArrived' notification fires in this circumstance, the selection should be up to date.
                    Please try the next nightly build, dated April 19 or above to pick this change up

                    Regards
                    Isomorphic Software

                    Comment

                    Working...
                    X