Question T15561
Visible to All Users

Ability to customize column filter and sorting when display survey answer list on table

created 2 years ago

Hi team,
I'm using the Tabulator table to display survey result records (the tutorial link is Export Survey Results to a CSV File | Form Builder for React - SurveyJS). Currently, the table support filtering and sorting by the text value displaying on the table. Does SurveyJS library support customizing the filter/sort of columns? For example:

  • Filter date column by date range
  • Filter dropdown column by a dropdown selection
  • Sort number by numerical order

Thanks

Answers approved by surveyjs Support

created 2 years ago (modified 2 years ago)

Hello,
Thank you for contacting us.

Header Filtering

By default, a SurveyJS Tabulator displays a filter box and supports LIKE filtering. However, you can use Tabulator API and enable filter editors in column headers.
After you render a tabulator, you can use the SurveyAnalyticsTabulator.Tabulator.tabulatorTables.updateColumnDefinition function to update a tabulator column definition and register required header filters.

Consider this example: View CodeSandbox. It shows how to enable the following type of header filters depending on a column.

JavaScript
vizPanel.render("surveyDashboardContainer"); vizPanel.columns.forEach((column) => { const questionName = column.question.name; switch (questionName) { case "submissionCount": vizPanel.tabulatorTables.updateColumnDefinition(questionName, { headerFilter: "number" }); break; case "userName": vizPanel.tabulatorTables.updateColumnDefinition(questionName, { headerFilter: "select", headerFilterParams: { values: true } }); break; case "submissionDate": vizPanel.tabulatorTables.updateColumnDefinition(questionName, { headerFilter: minMaxFilterEditor, headerFilterFunc: minMaxDateFilterFunction, headerFilterLiveFilter: false }); break; default: break; } });
  • The number filter for the column which stores numeric values.
    Clipboard-File-6.png

  • The select filter for the User Name column. This column contains user-input values. The select filter box displays available cell values.
    Clipboard-File-7.png

  • The Date Range editor for the date column.
    Clipboard-File-5.png

For more information on how to configure and customize header filters, please refer to Tabulator Documentation:

Sorting

Users can click Ascending/Descending to sort a numerical column. You can test this by sorting the 'How likely are you to recommend SurveyJS to a friend or colleague?" column.
Clipboard-File-1.png

I hope this example and information can help you. Should you have any further questions, please let me know.

Thanks

P.S. We hope you enjoyed the level of service you received. If so, we would love if you could leave your feedback on SurveyJS page at g2.com. As we’re building our business, every review helps build credibility for future customers and your feedback would be greatly appreciated.