Searching through here and it doesn't seem to find the answer.
I setup a pretty complicated grid with SlickGrid.
The search function is in a custom toolbar. Which I wire it up the call to the 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 I can see the argument getting pass to the custom filter
var customFilter = function(item, args) {
***$.each(args , function(key , val) {
if (val!=='' && val!==null) {
return (item[key] == val);
}
});***
return true;
}
[!] the problem is when you are inside the $.each , if you do "return" it only skip the loop. But there is nothing return to outside of the function.
BUT NOTHING HAPPENS ON THE GRID. NOTHING GET FILTERED
Here is my 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 the two filter examples from github. But I can't see any different apart from this
if I init the data view with
dataview = new Slick.Data.DataView({inlineFilters: true});
I get an error:
Uncaught SyntaxError: Undefined label '_coreloop' (slick.dataview.js line: 639)
Try to read the code but lack of comments ... so I really don't know what is the problem.
Anyone got the similar issue?
You can call this function if you declared the dataView and columnFilters as global variables:
function SetfilterOnGrid(SearchPhrase) {
columnFilters = {"1": SearchPhrase};
dataView.refresh();
}
The number "1" is the column ID the SearchPhrase is the phrase you are searching in the Grid
as for clearing the filters you can use this function:
function ClearFilterOnGrid()
{
columnFilters = {};
dataView.refresh();
}