Hi,
Im trying to retrieve the value of a checkbox that is inside of a template field using JavaScript on the following WebDataGrid:
<ig:WebDataGrid ID="dataGridBrands" runat="server" Height="350px" Width="100%"
AutoGenerateColumns="False"
StyleSetName="Office2007Blue">
<EditorProviders>
<ig:DropDownProvider ID="wdg_DiscountType">
<EditorControl DropDownContainerMaxHeight="200px" EnableAnimations="False" EnableDropDownAsChild="False">
<Button AltText="" />
<Items>
<ig:DropDownItem Selected="False" Text="None" ToolTip="None" Value="1">
</ig:DropDownItem>
<ig:DropDownItem Selected="False" Text="Percent" ToolTip="Percent" Value="2">
<ig:DropDownItem Selected="False" Text="Value" ToolTip="Value" Value="3">
</Items>
</EditorControl>
</ig:DropDownProvider>
<ig:NumericEditorProvider ID="wdg_Discount">
<EditorControl MinDecimalPlaces="2" NullValue="0" ValueText="0.00"
MaxDecimalPlaces="2" MaxLength="5" MinValue="0" Nullable="False"
NullText="0.00">
</ig:NumericEditorProvider>
</EditorProviders>
<Columns>
<ig:BoundDataField DataFieldName="Description" Key="Description" Width="180px">
<Header Text="Service" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="IdDiscountType" Key="IdDiscountType"
Width="160px">
<Header Text="Discount Type" />
<ig:BoundDataField Key="Discount" DataFieldName="Discount">
<Header Text="Discount Value" />
<ig:TemplateDataField Key="IsEnabled">
<ItemTemplate>
<asp:CheckBox ID="chkEnabled" runat="server"
Checked='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "IsEnabled") %>' />
</ItemTemplate>
<Header Text="Enabled" />
</ig:TemplateDataField>
<ig:BoundDataField Key="IdCarrier" DataFieldName="IdCarrier" Hidden="True">
<Header Text="IdCompanyCarrier" />
<ig:BoundDataField Key="IdCompanyCarrier" DataFieldName="IdCompanyCarrier"
Hidden="True">
<Header Text="IdCarrier" />
</Columns>
<Behaviors>
<ig:EditingCore AutoCRUD="False">
<ig:CellEditing Enabled="true">
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="Description" ReadOnly="True" />
<ig:EditingColumnSetting EditorID="wdg_Discount" ColumnKey="Discount" />
<ig:EditingColumnSetting ColumnKey="IdDiscountType"
EditorID="wdg_DiscountType" />
<ig:EditingColumnSetting ColumnKey="IsEnabled" />
<ig:EditingColumnSetting />
</ColumnSettings>
<EditModeActions MouseClick="Single" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
<ig:Paging PageSize="10" PagerAppearance="Bottom" />
<EmptyRowsTemplate>
No data to show
</EmptyRowsTemplate>
</ig:WebDataGrid>
I iterate thru the elements with the follwing JS:
var grid = $find("<%= dataGridBrands.ClientID %>");
var lst = document.getElementById("<%= lstProducts.ClientID %>");
lst.options.length = 0;
for (var i = 0; i < grid.get_rows().get_length(); i++) {
var row = grid.get_rows().get_row(i);
if (row.get_cell(3).get_value() == "true") { // <- here fails
lst.add(new Option(row.get_cell(3).get_value(),row.get_cell(3).get_value()));
}
That get_value() returns the whole INPUT tag but not the checkbox one... so ok, look at the attachment, i cannot even get the id with the method, but if i select manually the element by the reported Id from the get_value() method, it "works".
Please help me to solve it, i have allready 3 days workin on the same thing and its frustrating
thanks
I attach the mentioned screenshot
Hello,
Here is a sample code where I'm accessing the value of checkbox and the checkbox is placed inside WebDataGrid:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px"> <Columns> <ig:TemplateDataField Key="check"> <ItemTemplate> <asp:CheckBox ID="CheckBox1" Text="text" runat="server" /> </ItemTemplate> </ig:TemplateDataField> </Columns> </ig:WebDataGrid> <script type="text/javascript"> function findCheckBox() { var valueCheckBox = $find("WebDataGrid1") .get_rows().get_row(0) .get_cell(0).get_element() .children[0].checked; } </script>
Worked flawless, thank you!
if (row.get_cell(3).get_element().children[0].checked) { lst.add(new Option(row.get_cell(0).get_value(),row.get_cell(0).get_value())); }
I have a similar requirement, where in I have a WebNumericEditor in a webdatagrid. I am trying to get the value by doing something like :
row.get_cell(1).get_element().children[0].value;
But the value that I am getting by doing this is something like "|0|016||" ( when the value in the WebNumericEditor is 6).
Can anyone please help me with the right way to get the exact integer value of my WebNumericEditor.
Is there any documentation to tell what methods are available on the eventArgs parameter passed to the client side onclick event of the webdatagrid? I'm really struggling with trying to come up with a way to provide three unbound template columns that are checkboxes for each row of data in a table & when a person checks one of those checkboxes I want to check if any of the others are checked & if so uncheck them. Does that make sense? I'm a little new to JavaScript so I'm struggling.