2

我有一个带有过滤器类型文本框的列,并且我启用了过滤器行,但我需要过滤条件下拉列表也出现在文本框旁边,因为我需要能够应用多个条件,例如不等于和其他过滤器。

4

1 回答 1

0

It seems like it is possible, but only by making changes to the jqxgrid.filter module, which the licensing seems to allow. I base this answer on the code for jQWidgets v3.4.0. (Of course, it's convenient to de-minify the code first.)

There are switch statements in several functions which switch on the filtertype (such as number and textbox). You can define your own filtertype that shows a textbox with a dropdown list by choosing a new name and adding case statements to fall through to the number case in the function definitions _updatefilterrowui, clearfilterrow, and refreshfilterrow. For the function _addfilterwidget, you need to add your own case and copy the code for the number case, but replace the line saying

var A = F._getfiltersbytype("number");

with

var A = F._getfiltersbytype("string");

to populate the dropdown list with the string comparison operators – or you can define your own filtertype, but this of course requires additional adjustments. In the function _applyfilterfromfilterrow you also need to add a case based on the code for the number case, with some adjustments. Basically, what seems to do the trick is to firstly remove the part about the decimal separator and secondly to not typecast the input string by changing

y = k.createfilter(d, new Number(p), w, null, u.cellsformat, C.gridlocalization);

to

y = k.createfilter(d, p, w, null, u.cellsformat, C.gridlocalization);

Note that this answer is possibly not complete, as I haven't done extensive testing (but I am interested to know of any problems, as I am looking for the same functionality as BeyondProgramming).

于 2014-08-20T19:40:03.130 回答