Note that there are some explanatory texts on larger screens.

plurals
  1. POslickgrid search is not updating sometimes
    text
    copied!<p>I am using search filter in slickgrid for dataview model. It works sometimes fine but not always. </p> <p>For example, </p> <p>(1) My grid has 4 rows. </p> <p>(2) When I search for first row, the other 3 rows are removed(that's correct).</p> <p>(3) But again if I delete my search text, all 4 rows should appear ideally, but my grid shows 4 rows which contain the previously searched row twice.</p> <p>where am I wrong?</p> <p>Here is my Code for Filter function:</p> <pre><code>function myFilter(item, args) { if(item["myColumn"].toString().toLowerCase().indexOf(args.searchString.toLowerCase()) == -1){ return false; } else { return true; } } </code></pre> <p>Code for grid creation :</p> <pre><code>dataView = new Slick.Data.DataView(); grid = new Slick.Grid("#gridbox", dataView, columns, options); grid.setSelectionModel(new Slick.RowSelectionModel()); // initialize the model after all the events have been hooked up dataView.beginUpdate(); dataView.setItems(data); dataView.setFilterArgs({ searchString: searchString }); dataView.setFilter(myFilter); dataView.endUpdate(); grid.render(); grid.onSort.subscribe(function(e, args) { var cols = args.sortCols; dataView.sort(function(dataRow1, dataRow2) { for (i = 0, l = cols.length; i &lt; l; i++) { var field = cols[i].sortCol.field; var sign = cols[i].sortAsc ? 1 : -1; var value1 = dataRow1[field], value2 = dataRow2[field]; if((field.indexOf('providerName') != -1) || (field.indexOf('serviceAddress') != -1)) { value1 = value1.toLowerCase(); value2 = value2.toLowerCase(); } if(field.indexOf('providerName') != -1) { value1 = value1.replace(/[0-9]*/,''); value2 = value2.replace(/[0-9]*/,''); } var result = (value1 == value2 ? 0 : (value1 &gt; value2 ? 1 : -1)) * sign; if (result != 0) { return result; } } return 0; }); grid.invalidate(); grid.render(); bindClickOnRowCB(); }); grid.onScroll.subscribe(function(e) { grid.invalidate(); grid.render(); bindClickOnRowCB(); }); // wire up model events to drive the grid dataView.onRowCountChanged.subscribe(function (e, args) { grid.updateRowCount(); grid.render(); }); dataView.onRowsChanged.subscribe(function (e, args) { grid.invalidateRows(args.rows); grid.render(); }); // wire up the search textbox to apply the filter to the model $("#txtSearch").keyup(function (e) { Slick.GlobalEditorLock.cancelCurrentEdit(); // clear on Esc if (e.which == 27) { this.value = ""; } searchString = this.value; updateFilter(); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload