Announcement

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

    ListGrid Date Filter on Single User Entered Date

    Hello,

    I feel like I may be missing something simple but I haven't been able to find it in the documentation or showcase examples. We would like the filter editor for our date fields to just allow a user to enter a single date into the editor directly and hit enter to filter on that. By default, it uses the date range window and I haven't been able to figure out how to disable it. I did see in the documentation that a ListGridField does have filterEditorProperites but I have not found any information on what valid properties there may be.

    Any help would be greatly appreciated.

    Thanks!

    #2
    You can change the item-type via field.filterEditorType, which affects editorType for a field's formItem in the filterEditor.

    filterEditorProperties is a FormItem properties block, so you can apply any FormItem attributes, or attributes specific to the filterEditorType that you choose.

    In this case:

    Code:
    filterEditorType: "DateItem",
    filterEditorProperties: { useTextField: true }
    Last edited by Isomorphic; 5 Sep 2022, 22:56.

    Comment


      #3
      Perfect, thanks!

      Comment


        #4
        One more question... let's say we wanted all date fields application wide to inherit these properties in ListGrids. Is there an easy way to accomplish that? Right now, all of our ListGrids get their field list directly from the DataSource by marking fields we don't want to see as either hidden or detailed. Similarly, is there an easy way to have all filter editor fields across the whole application use text boxes by default?

        I'm sure it's a long shot, but thought I'd ask to avoid needing to go back in and manually define the field list for each ListGrid in the application in order to modify the filter editor properties.

        Thanks again!

        Comment


          #5
          You can set filterEditorType on your DataSourceFields

          If you want all DateItems in your app to use text-entry by default, you can do that by calling DateItem.addProperties({ useTextField: true }) before any widgets are created. This is a global default and affects all DateItems, whether in a ListGrid or not.

          Comment


            #6
            A quick follow-up on this - in fact, applying useTextField globally to DateItems is not the right approach here, because doing so allows a DateItem to have a null value, which has potential to affect the functionality of existing builtin and/or custom components that use DateItems.

            Instead, you can create a subclass of ListGrid that sets up your preferences for date fields before rendering, and use that custom grid pervasively in your app. You could override an API like draw() to apply your desired settings to the fields once at initial render before calling Super().
            Last edited by Isomorphic; 8 Sep 2022, 23:34.

            Comment

            Working...
            X