jquery - SlickGrid Custom Filter -
searching through here , doesn't seem find answer.
i setup pretty complicated grid slickgrid.
the search function in custom toolbar. wire call grid function.
for example:
[html]
<input name='name' id='id' class='searchable'>
[js]
$('.searchable').on('change' , function() { var searchterm = {}; searchterm[$(this).attr('name')] = $(this).val(); dataview.setfilterargs(searchterm); dataview.refresh(); });
and can see argument getting pass custom filter
var customfilter = function(item, args) { ***$.each(args , function(key , val) { if (val!=='' && val!==null) { return (item[key] == val); } });*** return true; }
[!] problem when inside $.each , if "return" skip loop. there nothing return outside of function.
but nothing happens on grid. nothing filtered
here setup
dataview = new slick.data.dataview(); grid = new slick.grid(grid_id , dataview , columns , options); grid.selectionmodel(new slick.rowselectionmodel()); grid.init(); dataview.beginupdate(); dataview.setitems(griddata); dataview.setfilter(customfilter); dataview.endupdate();
i have been following 2 filter examples github. can't see different apart this
if init data view with
dataview = new slick.data.dataview({inlinefilters: true});
i error:
uncaught syntaxerror: undefined label '_coreloop' (slick.dataview.js line: 639)
try read code lack of comments ... don't know problem.
anyone got similar issue?
you can call function if declared dataview , columnfilters global variables:
function setfilterongrid(searchphrase) { columnfilters = {"1": searchphrase}; dataview.refresh(); }
the number "1" column id searchphrase phrase searching in grid
as clearing filters can use function:
function clearfilterongrid() { columnfilters = {}; dataview.refresh(); }
Comments
Post a Comment