Hello,
I'm using VS2010 with 10.3 release. I have a webdatagrid with a template and a checkbox inside. I set the onclick event for the checkbox but it never fires. I tried to catch the cellvalue changing event and check for the column key but that didn't work either.
How can I have a client side event for the checkbox to perform some validation on it if it's checked/unchecked. I want to be able to check it only if another cell was edited and has values in it. If it doesn't then cancel or return flase and the check is cleared.
here's my checkbox code:
<ItemTemplate> div style="text-align: center;"> asp:CheckBox ID="CheckSpecific" runat="server" AutoPostBack="true" Checked='<%# Bind("IsSpecific") %>' OnCheckedChanged="CheckSpecific_CheckedChanged" /> div> ItemTemplate>
Thanks,
Hello marcgh,
Please follow the link for ideas on how to access checkbox events in a templated field:
http://forums.infragistics.com/forums/p/25183/92986.aspx#92986
In version 11.1 we have implemented BoundCheckBoxField which I strongly recommend.In it you could use the Editing_CellValueChanging client side event for the setting state of the CheckBox and the CellEditing_ExitingEditMode for catching changes in the other columns.
I hope this was helpful. Don't hesitate to ask if you have further questions.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Ok the way I did was is:
On row Initialize I find the checkbox and add the attributes to it:
var check = e.Row.Items[14].FindControl("CheckSpecific") as CheckBox;checkbox.Attributes.Add("onclick", "return CheckSpecific('" + recordId + "');");The record id is from: var recordId = ((MyObject) e.Row.DataItem).RecordId;
In the javascript method, i looped thru all rows to find the row with the same ID then add the logic I needed:
function CheckSpecificTaxLot(rowId) { var grid = $find('<%= wdg.ClientID %>'); var gridRows = grid.get_rows(); var length = gridRows.get_length(); for (var i = 0; i < length; i++) { row = gridRows.get_row(i); var id = row.get_cellByColumnKey("RecordId").get_value(); if (id == rowId) { // logic here ... // ... return (..boolean ..) ? false : true; } } return false;}
Is this is the way to do or maybe there is a more efficient way?
Have you been able to resolve your issue ?
If you still have any concerns or questions I will be glad to help.
Your solution seems reasonable and I can’t think of a different approach right now. Go ahead and use it.
If you need further help with this don’t hesitate to ask.