In my .aspx page I have an Itemtemplate code to display a RadioButtonList:
<ig:TemplateDataField Key="TemplateField_Status"> <Header Text="Status"> </Header> <ItemTemplate> <asp:RadioButtonList ID="rblStatus" runat="server" RepeatDirection="Horizontal"> <asp:ListItem Selected="True" style="padding-right:25px;">Exclude Time</asp:ListItem> <asp:ListItem style="padding-right:25px;">Stop</asp:ListItem> <asp:ListItem>Complete</asp:ListItem> </asp:RadioButtonList> </ItemTemplate> </ig:TemplateDataField>
I have a button on the web page that calls JavaScript code and I'd like to change all the rows in the grid to have the "Complete" ListItem selected. How do I reference the radio button so I can set the "Complete" radio button for each row?
I didn't figure out how to do this client-side, but I am able to set the radio buttons server-side.
Using the following code I was able to set the radio button in code-behind using C#:
WebDataGrid grid = WeldsDataGrid; RadioButtonList rbl_response;
foreach (GridRecord row in grid.Rows) { rbl_response = (RadioButtonList)row.Items[4].FindControl("rblStatus"); rbl_response.SelectedValue = "Complete"; }
Hello Chris,
Apologies for the delayed answer.
You can easily do this job on the client-side like so:
var rows = $find("WebDataGrid1").get_rows();var rowsLength = rows.get_length();for (var i = 0; i < rowsLength; i++) { var row = rows.get_row(i); var cell = row.get_cellByColumnKey("TemplateField_Status"); var cellElement = cell.get_element(); $(cellElement).find("input[value='Complete']").prop("checked", true);}
I am attaching a working sample in case you need it.
Please let me know if you need anything else.