Announcement

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

    Filter by different values

    Hey,

    I have a ListGrid with filter and a numeric column.

    Before showing the value in the client, i modify the record while doing the "fetch" so it will show the value with a thousand separator (","). for example if i need to show 9999 i will show 9,999

    is it possible to enable the user to filter by entering "9999" or "9,999" and in both cases to get the same results?

    and how do i make sure that if he entered just "9", it will not show "9,999"?

    Thanks!
    Yoni

    #2
    Don't format the value at the server - send it to the client as a number (in a DS field of numeric type) and override field.formatCellValue() to format it however you like

    Comment


      #3
      but what if i want to format it in the server?

      Instead of changing the value itself, during fetch I added a record to the ds field called formatCellValue with the wanted value (in my example return '9,999'). but the client already "built" the grid using the ds, and the change has no effect. how can i do it?

      Comment


        #4
        By formatting the value at the server, you change it's type to String, so you get string filtering based on whatever you type at the client.

        If your DS field is defined with a numeric type, returning it as a formatted string is just a breakage.

        You should leave the field as numeric in the datasource and just add a formatCellValue() override to the field definition in your grid that returns the numeric value formatted as you require.

        Comment


          #5
          ok,
          is there a way to modify the default filter function?

          lets say i want to get the same result in the grid when i enter 9999 or 9,999 in the filter

          Comment


            #6
            You could use a parseEditorValue / formatEditorValue pair on the listGridField filterEditorProperties to customize how the user-entered value is parsed into actual filter criteria.

            Comment

            Working...
            X