Shesha Shesha - 6 months ago 66x
Javascript Question

mleibman/SlickGrid Adding clear button

how to reset search options in mleibman/SlickGrid I want to add a Clear Filter Button.

Just want to know his there any built-in function avaliable or we need to write a custom
function for that


Here is a short version of it working, I tested it as well.

// remove the text inside each search input fields

// empty out all column filters within the columnFilters object & refresh dataview
for (var columnId in columnFilters) {
    columnFilters[columnId] = "";

The columnFilters variable is very important but maybe named differently depending on your code, but if you look at this Slickgrid Example you can see that it's defined as var columnFilters = {}; and then make sure you have this piece of code:

$(grid.getHeaderRow()).delegate(":input", "change keyup", function (e) {
  var columnId = $(this).data("columnId");
  if (columnId != null) {
    columnFilters[columnId] = $.trim($(this).val());

which is attaching all your inputs to that the object variable columnFilters... then only after you can use the code I gave (which is working for me as I tested it)