Hello,
I have a grid that has columns of data. The first row of each column is a boolean. I would like to display that row as checkboxes to permit a user to check or uncheck that particular box.
Help!
Thanks,
Michael
I am attaching a sample that does a similar functionality, with the check boxes displayed in the header.
In the sample provided I am creatimg to templated columns and assigning checkboxes at the header. In the InitilaizeLayout event I am checking/unchecking the CheckBoxes at the header according to the values in the first row using the following code snippet:
if (e.Row.Index == 0) { e.Row.Hidden = true;
foreach (UltraGridCell cell in e.Row.Cells) { TemplatedColumn tc = cell.Column as TemplatedColumn; HeaderItem item = tc.HeaderItem as HeaderItem; CheckBox checkbox1 = item.Controls[1] as CheckBox;
checkbox1.Checked = ((int) cell.Value) != 0; }
}
On the client side I attached an event when the checkbox is fired. First I check the column that was checked, and I get the first row in the Grid and I assign it the value using the following code snippet:
function HeaderCheckedChanged(sender){ var grid = igtbl_getGridById("<%= UltraWebGrid1.ClientID %>"); var column = igtbl_getColumnById(sender.parentElement.id);
if (column == null) { alert("Debugging: Column is null"); return; } var index = column.Index; myrow = gridID.Rows.getRow(0);var cell_value = myrow.getCell(index).getValue();
if((cell_value) == 0) { myrow.getCell(index).setValue(1); } else myrow.getCell(index).setValue(0);
Magued