Adding Filter Icon in Extjs Grid Column once after Filter is applied

蓝咒 提交于 2020-03-03 09:06:48

问题


Is there anyway we can highlight column with filter is applied. The same way when we do sorting an icon is added on the individual column level to notify user.

Thanks in advance.


回答1:


This question is bit similar to Filter Header Update Any way to Achive this what my approach is first You need to prepare one css which having image what exactly you want. Your code for css look like or change as per your need :

.filtered-column {    
 background:url(http://dev.toadformysql.com/webhelp/...fiedFilter.png) no-repeat !important; 
 background-position: calc(100% - 5px) 3px !important;
}

In filter class call the css

newCls : 'filtered-column',

Then In your own updateColumnHeadings method and use the below code.

updateColumnHeadings : function () {
    var view = this.grid.getView(),
        i, len, filter;
    if (view.mainHd) {
        for (i = 0, len = view.cm.config.length; i < len; i++) {
            filter = this.getFilter(view.cm.config[i].dataIndex);
            Ext.fly(view.getHeaderCell(i))[filter && filter.active ? 'addClass' : 'removeClass'](this.newCls); // In this line we are adding the newCls which will aply for filter.
        }
    }
},

Note : I checked in My filter and it works. If your filter is customize in your requirement then there is chance it won't work but ideally this is the way to update applied filter header.



来源:https://stackoverflow.com/questions/39209855/adding-filter-icon-in-extjs-grid-column-once-after-filter-is-applied

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