I have a couple simple WebDataGrids that I want to provide very simple wildcard search boxes for. Yes, the filter row would be a good solution, if I could use it. My search must be at the bottom of my grid, but the filter row is placed below the last row of data, which means you must SCROLL to the bottom of the grid to see the filter row.
Anyway, my problem is that I can not find the documentation for the CSOM for the WebDataGrid. I have deduced that there is no ig_getGridById utility function or similar for retrieving the grid object, so I'm using var oGrid = $find("<%= gridEmployees.ClientID %>"); to find the WebDataGrid object via javascript.
My question is: How do I do a client-side filter from here? I've seen an example for how to search through the data one row at a time, but that seems a bit archaic considering we're dealing with an AJAX-enabled control. I should have a mechanism for doing client-side filtering using javascript.
Can anyone help me?
Thanks, Bryan
Bryan,
Here is some code that I use
var grid = ig_controls["WebDataGrid1"]; var filtering = grid.get_behaviors().get_filtering(); var key = document.getElementById("colKeyTextbox").value; var val = document.getElementById("filterTextbox").value; var newFilter = filtering.create_columnFilter(key); newFilter.get_condition().set_value(val); newFilter.get_condition().set_rule(3); filtering.add_columnFilter(newFilter); filtering.applyFilters();
The int passed into the set_rule function is the int representation of the enum for FilterRules for the column you're filtering. So for an int, it'll have choices 0-6 where they represent the index in the drop down and the enum.
This should get you started. Post back if you need further help.
-Dave
do you happen to know how to clear the filters as well via client side code?