registerFilter

registers a filter element

void registerFilter(HTMLElement| object object,object config,object controller);

Parameters

objectHTMLElement| objectnode in case of HTML input or the control's object
configobjectthe hash of settings
controllerobjectthe controller object

Example

// registering HTML input as a filter
grid.registerFilter(document.getElementById("myfilter"), 
    { columnId:"title" }, 
    {
        getValue:function(object){
            return object.value;
        },
        setValue:function(object, value){
            object.value = value;
        }
    }
);
 
// registering List as a filter 
grid.registerFilter(
  $$("myfilter"),   // is stored as 'list' parameter in 'getValue'
  { columnId:"year" },  // a column to filter
  {
    getValue:function(list){
      var selection = list.getSelectedId();
      var item = list.getItem(selection)
      var filterValue = item.filter;
      return function(year){
        return year > filterValue 
      }
    }
  }
);

Related samples

Details

In the above mentioned sample:

  • the input with 'myfilter' ID becomes filter for a datatable column with 'title' ID;
  • the getValue method of the newly created filter gets the value from its HTML node and sets it as filtering parameter.
See also
Back to top
If you have not checked yet, be sure to visit site of our main product Webix mvc library and page of javascript datagrid library product.