Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
485
WHDG Parent Child Checkbox check uncheck
posted

Hi

Please have a look of the below code:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid5" runat="server" Height="500px" ClientIDMode="Static" InitialDataBindDepth="2" Width="100%" DataKeyFields="CustomerId" AutoGenerateColumns="False" >

 

 

 

<ClientEvents Click="ClickHandler_jquery" RowExpanded="RowExpandHandler" /> <Columns>

<ig:TemplateDataField Key="ParentCheckBox">

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<asp:CheckBox ID="CheckBox2" runat="server" />

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

</ig:TemplateDataField>

 

 

 

 

 

<ig:BoundDataField DataFieldName="CustomerId" Key="CustomerId" Header-Text="Customer ID"><Header Text="Customer ID"></Header></ig:BoundDataField>

 

 

 

 

 

<ig:BoundDataField DataFieldName="CustomerName" Key="CustomerName" Header-Text="Customer Name"><Header Text="Customer Name"></Header></ig:BoundDataField>

 

 

 

 

 

<ig:BoundDataField DataFieldName="CustomerMName" Key="CustomerMName" Header-Text="Customer M Name"><Header Text="Customer M Name"></Header></ig:BoundDataField>

 

 

 

 

 

<ig:BoundDataField DataFieldName="CustomerLName" Key="CustomerLName" Header-Text="Customer L Name"><Header Text="Customer L Name"></Header></ig:BoundDataField>

 

 

 

 

 

<ig:BoundDataField DataFieldName="CustomerAdd" Key="CustomerAdd" Header-Text="Customer Add"><Header Text="Customer Add"></Header></ig:BoundDataField>

<ig:BoundDataField DataFieldName="CustomerCity" Key="CustomerCity" Header-Text="Customer City"><Header Text="Customer City"></Header></ig:BoundDataField>

 

 

 

 

 <ig:BoundDataField DataFieldName="CustomerState" Key="CustomerState" Header-Text="Customer State"><Header Text="Customer State"></Header></ig:BoundDataField>

 

 

 

  <ig:BoundDataField DataFieldName="CustomerCountry" Key="CustomerCountry" Header-Text="Customer Country"><Header Text="Customer Country"></Header></ig:BoundDataField>

 

 

 

  <ig:BoundDataField DataFieldName="CustomerLandMark" Key="CustomerLandMark" Header-Text="Customer LandMark"><Header Text="Customer LandMark"></Header></ig:BoundDataField>

 

 

 

 <ig:TemplateDataField Key="CustomerInfoDispatch"><ItemTemplate> <ig:WebDropDown ID="ddlCustomerInfoDispatch" runat="server" Width="100px"></ig:WebDropDown></ItemTemplate></ig:TemplateDataField>

 

 

 

 <ig:TemplateDataField Key="CustomerSendPromoDetails"><ItemTemplate></ItemTemplate> </ig:TemplateDataField> </Columns>

 

 

 

 <Bands>

 

 

 

 <ig:Band DataMember="OrderList" DataKeyFields="OrderId" Key="OrderId" AutoGenerateColumns="false">

<Columns>

 

 

 

 <ig:TemplateDataField Key="BandOneCheckBox"><Header Text="CheckBox" /> <ItemTemplate><asp:CheckBox ID="CheckBox1" lientIDMode="Static" runat="server" /> </ItemTemplate></ig:TemplateDataField> 

<ig:BoundDataField DataFieldName="CustomerId" Key="Customer" Header-Text="Customer ID"><Header Text="Customer ID"></Header></ig:BoundDataField>

 

 

 

 <ig:BoundDataField DataFieldName="OrderId" Key="OrderId" Header-Text="Order Id"><Header Text="Order Id"></Header></ig:BoundDataField>

 

 

 

 <ig:BoundDataField DataFieldName="OrderName" Key="OrderName" Header-Text="Order Name"><Header Text="Order Name"></Header></ig:BoundDataField></Columns>

 

 

 

 <Bands>

 

 

 

 <ig:Band DataMember="ProductList" DataKeyFields="ProductId" Key="ProductId" AutoGenerateColumns="false">

<Columns>

 

 

 

 <ig:TemplateDataField Key="BandTwoCheckBox"> <Header Text="CheckBox" /><ItemTemplate><asp:CheckBox ID="CheckBox3" ClientIDMode="Static" runat="server" /></ItemTemplate></ig:TemplateDataField>

 

 

 

 <ig:BoundDataField DataFieldName="ProductId" Key="ProductId" Header-Text="Product Id"><Header Text="Product Id"></Header></ig:BoundDataField>

 

 

 

 <ig:BoundDataField DataFieldName="OrderId" Key="OrderId" Header-Text="Order Id"><Header Text="Order Id"></Header></ig:BoundDataField>

 

 

 

 <ig:BoundDataField DataFieldName="ProductName" Key="ProductName" Header-Text="Product Name"><Header Text="Product Name"></Header></ig:BoundDataField>

 

 

 

 </Columns>

 

 

 

 </ig:Band>

 

 

 

 </Bands>

 

 

 

 </ig:Band>

 

 

 

 </Bands>

 

 

</ig:WebHierarchicalDataGrid>

and JAVA SCRIPT Function is :

 

 

var isChecked = false;

 

 

function ClickHandler_jquery(sender, args) {

 

 

//debugger;

 

 

if (args.get_item() != null) {

 

 

var grid = $find("WebHierarchicalDataGrid5");

isChecked = args.get_item().get_row().get_cell(0).get_element().children[0].checked;

 

 

var rowIndex = args.get_item().get_row().get_index();

 

 

var parentGrid = grid.get_gridView();

 

 

if (args.get_item()._column._key == "ParentCheckBox") {

ClickHandler_band1(grid, isChecked);

 

 

//ClickHandler_band2(grid, isChecked);

}

 

 

else if (args.get_item()._column._key == "BandOneCheckBox") {

ClickHandler_band2(grid, isChecked);

}

}

}

 

 

function RowExpandHandler(sender) {

 

}

 

 

function ClickHandler_band1(grid, value) {

 

 

var ChildBand = GetBand1(grid, 0); //grid.get_gridView().get_rows().get_row(0).get_rowIslands(0)[0];

SelectBandRows(ChildBand, value);

}

 

 

function ClickHandler_band2(grid, value) {

 

 

var ChildBand = GetBand2(grid, 0);

SelectBandRows(ChildBand, value);

}

 

 

function GetBand1(grid, RowIndex) {

 

 

return grid.get_gridView().get_rows().get_row(RowIndex).get_rowIslands(0)[0];

}

 

 

function GetBand2(grid, RowIndex) {

 

 

return grid.get_rows().get_row(RowIndex).get_rowIslands()[0].get_rows().get_row(RowIndex).get_rowIslands()[0];

}

 

 

function SelectBandRows(ChildBand, value) {

 

 

for (var i = 0; i < ChildBand.get_rows().get_length(); i++) {

CheckUnchek(ChildBand.get_rows().get_row(i), value);

}

}

 

 

function CheckUnchek(Row, value) {

Row.get_cell(0)._element.children[0].checked = value;

 

 

if (Row._rowIslands) {

 

 

if (Row._rowIslands[0].get_rows().get_length() > 0) {

SelectBandRows(Row._rowIslands[0], value);

}

}

}

I am not able to check unchek the parent and child check box. The javscript function gives me the first row and all its child nodes cehck uncheck if all nodes are expanded. I am not able to get the row index of the clicked node.

Can anyone help me out in this issue this is very critical issue for me right now. Please provide the code if possible or make my code working.

Thanks in Advance

Regards,

Nilesh