Hello All,
I am using a grid with 'GridClientSelectColumn' to display a column of checkboxes. Also this displays a checkbox on the header which is again useful to me. I want to call a javascript function on the individual checkboxes . I would also like to call another javascript function when the checkbox in header is checked\unchecked.
I could not find any help about how to do this. It might be an easy thing and I am missing something .
Please advise.
Thanks in advance.
Regards
Yogendra
I am using a grid with 'GridClientSelectColumn' to display a column of checkboxes. Also this displays a checkbox on the header which is again useful to me. I want to call a javascript function on the individual checkboxes . I would also like to call another javascript function when the checkbox in header is checked\unchecked.
I could not find any help about how to do this. It might be an easy thing and I am missing something .
Please advise.
Thanks in advance.
Regards
Yogendra
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Oct 2012, 04:18 AM
Hi,
Try the following code to attach javascript for ClientSelectColumn.
C#:
JS:
Thanks,
Shinu.
Try the following code to attach javascript for ClientSelectColumn.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; CheckBox chk = (CheckBox)item["select"].Controls[0]; chk.Attributes.Add("onclick", "custom1();"); } if (e.Item is GridHeaderItem) { GridHeaderItem headeritem = (GridHeaderItem)e.Item; CheckBox chk = (CheckBox)headeritem["select"].Controls[0]; chk.Attributes.Add("onclick", "custom2();"); }}function custom1(){//for other checkboxes
}function custom2() {//for header checkbox}Thanks,
Shinu.
0
Yogendra
Top achievements
Rank 1
answered on 16 Oct 2012, 11:53 PM
Thanks for the answer Shinu. That works
I have another problem now. I am using the select column to select bunch of values (called KPIs) for a scheduled job. In edit of the job, I need to select those checkboxes again. I tried doing that in the itemdatabound event of the grid, but the checkboxes were not checked.
Any advise.
I have another problem now. I am using the select column to select bunch of values (called KPIs) for a scheduled job. In edit of the job, I need to select those checkboxes again. I tried doing that in the itemdatabound event of the grid, but the checkboxes were not checked.
Any advise.
0
Shinu
Top achievements
Rank 2
answered on 17 Oct 2012, 05:16 AM
Hi,
Try the following code to make the Clientselectcolumn selected in edit mode.
C#:
Thanks,
Shinu.
Try the following code to make the Clientselectcolumn selected in edit mode.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ if (e.Item is GridEditFormItem && e.Item.IsInEditMode) { GridEditFormItem editItem = (GridEditFormItem)e.Item; GridDataItem item = (GridDataItem)editItem.ParentItem; // accessing parent row of edit form CheckBox chk = (CheckBox)editItem["select"].Controls[0]; item.Selected = true; }}Thanks,
Shinu.
0
Yogendra
Top achievements
Rank 1
answered on 17 Oct 2012, 05:17 PM
Hello Shinu,
Appreciate the answer. The edit works
Clicking the header checkbox does not select\deselect all the rows in the grid WHEN custom javascript is called on the header checkbox.
Any ideas how to fix this ?
Thanks
Yogendra
Appreciate the answer. The edit works
Clicking the header checkbox does not select\deselect all the rows in the grid WHEN custom javascript is called on the header checkbox.
Any ideas how to fix this ?
Thanks
Yogendra