Slickgrid filter on formatted cell content

南笙酒味 提交于 2019-12-11 20:18:20

问题


For a new project we are using SlickGrid which is a very neat tool for displaying grid data. We are trying to implement a search box above the grid which filter the content of the grid. We're using a DataView with the grid and we can use the functions 'setFilter' and 'setFilterArgs' to implement the filter on the DataView.

We also use custom formatters to format the content of the cells for some fields. For example the country is a country code in our data object (for example 'NL') but we use a formatter in the grid column definitions to display it as the translated value 'Netherlands'. Also dates are formatted this way.

The problem is: We can only filter on the content in the data object because it is accessible from the DataView, but we need to filter on the formatted content which is presented in the cells by the grid. Is there any way to get this done in a fast and good way ?


回答1:


CPU efficient way: in your formatter function, assign, just before your return statement:

dataContext.countryName = myFullCountryName;

This will add a new property to the item/row. Then when you're sorting on the country column, simply reference the countryName instead.

The memory efficient way would be to simply pass each country value through your formatter function before doing the comparison in your sorting function.



来源:https://stackoverflow.com/questions/13585994/slickgrid-filter-on-formatted-cell-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!