Search code examples
jsgrid

"Empty option" when filtering


I have a grid with several columns, most of which have values selectable from a given set. (i.e. they are shown as dropdown boxes when inserting/updating.) I want to enable filtering, but not necessarily on all columns at once. So I tried adding an empty option for each column, but this means it also shows up in the dropdown for insert/update, which is not what I want.

So how should I solve this? Do I need to override one or more of the row renderer functions?


Solution

  • You can redefine filterTemplate of the column like the following:

    filterTemplate: function() {
      var $select = jsGrid.fields.select.prototype.filterTemplate.call(this);
      $select.prepend($("<option>").prop("value", "0").text("(All)"));
      return $select;
    }
    

    Here is the working fiddle http://jsfiddle.net/tabalinas/g68ofLs1/