Announcement

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

    Do I need "search" or "submit" for the "searchForm" property of a ListGrid?

    When looking at the Overview tab of the SearchForm documentation (I'm looking at the current on-line reference dated 2024-04-13), it says:

    A SearchForm may be bound directly to a ListGrid by applying it to ListGrid.searchForm. Doing this ensures that when search() is invoked (from a submit button click or Enter keypress), the grid will be filtered by the values from the search form.
    There's also an example related to the "searchForm" property of the ListGrid class (https://smartclient.com/smartclient-...ieredFiltering) which uses:

    Code:
    itemChanged: function (item, newValue) {
      this.submit();
    }
    I'm a bit confused if this conflicts or that it doesn't matter which one to use.

    #2
    Hi wallytax see also https://smartclient.com/smartclient-...rid.searchForm

    an alternative to trigger a submit in the itemChanged is to have a filterOnKeypress:true on the grid.

    Comment


      #3
      Hi claudiobosticco, thanks for your reply!

      Looking at the documentation of "searchForm", it states:

      If the FilterEditor is enabled and listGrid.filterOnKeypress is set, the grid will automatically watch for SearchForm.criteriaChanged(), and filter whenever that method fires. For the purposes of this behavior, the FilterEditor is considered to be enabled even if it is not currently visible but canShowFilterEditor is true (as otherwise filtering behavior in the form would change when the FilterEditor appears).
      I tried setting "filterOnKeyPress" to true in the grid and removed the "itemChanged" method and indeed, what you described works! But then I tried setting "canShowFilterEditor" to false, assuming the behavior is disabled, but it still works. I don't think that's inline with the quote above?!

      But for me, more important to not use that "filterOnKeyPress" property, is that my search form contains a text box to enter a search text. And now it more or less immediately fires a submit when typing in characters. Is there a way to disable it per field?

      Hope this is clear enough?

      Comment


        #4
        Per the docs, SearchForm.search() is a notification event, so it's something you implement, not something you call yourself. To cause a SearchForm to take its action, you call submit() (just as with other forms).

        You can use the itemChanged() approach shown in the sample to cause the SearchForm to take its action on any change. You can set filterOnKeypress to cause more frequent filtering, but since you've said you don't want that, then you should simply not set that property.

        Comment


          #5
          Thanks for the replies, I will change my code to use submit() and per-field change events.

          Comment


            #6
            Just for 100% clarity: the docs say the method is invoked from a submit button click of Enter keypress. But does it also fire when you manually call submit()?

            Comment


              #7
              I've checked the functionality I mentioned in the previous comment and indeed search() is called when calling submit().

              Comment

              Working...
              X