Hi I need a ultrawebgrid with column(0) as checkbox. When I check the header checkbox i have to check all the checkboxes in the column(0).
how to do this. early response would be greatly appreciated.
Thanks,
ATMY@chevron.com
You can use the following code to select/deselect all the checkboxes when a header checkbox is checked.
$('#headerCheckbox').click(function () { var isheaderChecked = this.checked; $(".childCheckBox").each(function () { this.checked = isChecked; }) })
Also when you uncheck any one of the child checkbox you need to uncheck the header checkbox also, for that code, look at this post:
http://coding-issues.blogspot.in/2013/10/check-uncheck-all-checkboxes-jquery.html
Here is my code, where I have Column with checkboxes and header is checkbox too. When header checkbox is selected all cell's checkboxes are selected too. If in one of the cell the checkbox is unchecked, uncheck the header too.
// html markup
<igtbl:TemplatedColumn basecolumnname="Read" key="Read" type="CheckBox" datatype="System.Boolean" allowupdate="Yes" width="20px"> <HeaderTemplate> <input id="chboxNotificationsHeaderCheck" onclick="checkHeader_OnClick_Read('<%= GridNotificationSortByRead.ClientID %>',this)" type="checkbox"> </HeaderTemplate> <HeaderStyle customrules="padding: 0px; text-align: right;"></HeaderStyle></igtbl:TemplatedColumn>
..........
<ClientSideEvents AfterCellUpdateHandler="grid_OnAfterCellUpdate_Read" />
// javascript code
// Function for grids where the check column name is "Read"function grid_OnInitializeLayout_Read(gridName){ // Check all Rows checkboxes if they are checked var checkboxColumnName = "Read"; var oGrid = igtbl_getGridById(gridName); for(var i = 0; i < oGrid.Rows.length; i++) { var oRow = oGrid.Rows.getRow(i); var cell = oRow.getCellFromKey(checkboxColumnName); var cellCheckValue = oRow.getCellFromKey(checkboxColumnName).getValue(); // if at least one is unchecked, set the variable and return from the function if (!cellCheckValue) { document.getElementById(cell.Column.Id).children[0].checked = false; return; } } // Change Header checkbox document.getElementById(cell.Column.Id).children[0].checked = true;}// Function for grids where the check column name is "Read"function checkHeader_OnClick_Read(gridName, cellId){ var checkboxColumnName = "Read"; var oGrid = igtbl_getGridById(gridName); var oRows = oGrid.Rows; var cellEvent = oGrid.Events.AfterCellUpdate[0]; oGrid.Events.AfterCellUpdate[0] = ""; for(var i = 0; i < oRows.length; i++) { var oRow = oRows.getRow(i);
// this calls AfterCellUpdate, that is why we use IsInHeaderClickHandler oRow.getCellFromKey(checkboxColumnName).setValue(sender.checked); // This works only for the multi bind grids, for other cases the count is 0 for(var j = 0;j < oRow.ChildRowsCount; j++) { chRowId = oRow.Id + "_" + j.toString(); oChRow = igtbl_getRowById(chRowId); oChRow.getCellFromKey("IsSelectedChild").setValue(oRow.getCellFromKey(checkboxColumnName).getValue()); } } oGrid.Events.AfterCellUpdate[0] = cellEvent;}
-------------------------------------------------------------------------------------------------------------------------------------------
And everything was fine, before I put the last version of the Infragistics controls. Now in some button event handler (when my button is clicked), the new state of the checkboxes isn't right. All rows are with Unchanged data.
I don't know how to fix this problem. Pls, help
Iva
I tried getting the code examples above to work but did not have any success. What is calling
function igrdInitializeLayout(object)? Do I need to make a call to this function somewhere?
Thanks
ok I found it hope this helps someone else save some time, this worked for me
var object = eval(oGrid.Rows.getRow(i).getCell(0).getValue(checked));
{
oGrid.Rows.getRow(i).getCell(0).setValue(true);
else
}
Ok I got it to work! half way though!! how can I check the value and select / and unselect all?? right now it selects everything but I cant seem to figure a way out to revesr it I tried doing this
//oGrid.Rows.getRow(i).getCell(0).setValue(checked);
alert(object)
but this does not work how can I evaluate the property and reverse it based on the value? I cannot seem to set the value to false or uncheck?!?