jQuery UI Widgets Forums DataTable Filtering on Data Model instead of Presentation/View

This topic contains 1 reply, has 2 voices, and was last updated by  Vladimir 8 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • apelton
    Participant

    Hello,

    This question is related to the example at: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdatatable/index.htm#demos/jqxdatatable/javascript-datatable-rows-rendering.htm

    In the example, instead of the data columns being rendered in the table directly, they are combined to form html component record cells. In the design I’m making, I want to programmatically filter based on the data fields in the source included in the data adapter on the table. However, these fields are not columns on the table. Note in the example that the only true column is ‘Products.’

    I performed an experiment just now where when I specify a filter using any of the fields from my data source, then the filter callback handler shows that no filters are in the event args array. However, when I list ‘Products’ as the field to filter on, the filter callback handler does contain the filter applied in the event args array. This behavior suggests that filtering is applied on the presentation layer of the grid and not the underlying data source model.

    Is there a way in the API to filter based on the data model fields even if the field is not present in the data table?

    P.S.
    I’m aware that you can perform server side filtering. However in my case I actually have a couple of grids on the page that reference the same data source but that are programmatically filtered to show specific subsets. This reduces the need to invoke 3 separate ajax/rest calls, and share the results of one rest call amongst 5 tables.


    Vladimir
    Participant

    Hello apelton,

    It is not possible to use the dataTable filters in the scenario you are describing. You can however implement your own custom filtering of records before supplying them to the dataTable (probably at the same stage where you seperate your data, or updating them whenever you need by using the stored data from the original request). Remember that the data is basically an array, and arrays filter() method supports custom filtering. Here is a useful filtering explanation.

    When you have programatically filtered your data, just call dataAdapter.dataBind() to bind to the filtered data, and it should update as expected. Similarly you can remove the filter.

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.