is there a way to make the header click action for an unboundcheckboxfield apply to only the rows in the current filter? I have a datagrid with a list of jobs and I want to select all of the jobs with "engineer" in the title. I should be able to filter on job title and then click the header of my select column to check only those records.
Hello Peggy,I'm not sure if I understand you correctly. If the current filer is applied then you will have only filtered results in the grid. Then if you click on the unboundcheckbox’s header it will check all rows in the grid.But if you want to check only the rows that contain “engineer” you could do something like this:
function WebDataGrid1_Grid_HeaderCheckBoxClicking(sender, eventArgs)
{
eventArgs.set_cancel(true);
var grid = $find('<%=WebDataGrid1.ClientID %>');
var rows = grid.get_rows();
for (var i = 0; i < rows.get_length(); i++) {
var row = rows.get_row(i);
var cell = row.get_cellByColumnKey("jobs").get_text();
var text = String(cell).match("engineer");
if (text) {
var checkBoxCell = row.get_cellByColumnKey("CheckBox");
checkBoxCell.set_value(true);
}
Enable editing and handle HeaderCheckBoxClicking event
I don't want to set the checkbox values in code. I need the user to be able to do that. Right now, if I filter the grid (not in code) to show only the engineers and then click the unboundcheckbox header to select them it does mark them true. However, when I clear the filter all of the jobs are checked. It should only have checks in the engineer jobs that I had filtered.
Hi Peggy,
in this case handle DataFiltering event. Check if "Clear Filter" is selected and uncheck these checkboxes:
function WebDataGrid1_Filtering_DataFiltering(sender, eventArgs)
//get filter value
var value = eventArgs.get_columnFilters()[0].get_condition().get_value();
//get filter rule
var rule = eventArgs.get_columnFilters()[0].get_condition().get_rule();
//Check if selected filter is "Clear filter"
if (value == null && rule == 0) {
checkBoxCell.set_value(false);
Please let me know if this helps