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
230
RowUpdating event not firing for ItemTemplate change
posted

I am facing two issues in WebHierarchicalDataGrid.

Issue # 1:

I have a WebHierarchicalDataGrid which has three levels. In each level I have Add. Edit and Delete checkboxes in ItemTemplate(TemplateDataField) for each row. I am expecting that if I check/uncheck any checkbox in any level and press my Save button ultimately RowUpdating event will be called for each edited row whereas this not happening. If I use BoundCheckBoxField instead of ItemTemplate checkboxes it works as expected. Please see ASPX sample code for rest of the details.

The reason to change BoundCheckBoxField to ItemTemplate checkbox field is I have to write javascript code that if my Parent is selected then child checkboxes should be unselected and vice versa. I am not able to get BoundCheckBoxField checkbox in the javascript, it comes as 'undefined' whereas I am able to get the ItemTemplate checkboxes in javascript.

Issue # 2:

In the same above grid when I am using BoundCheckBoxField and try to select Add. Edit, Delete checkboxes then in my RowUpdating event I only get Add checkbox value as "true" rest are coming as false. If I run my code again some time I got correct checkbox value and some time not. Please C# code.

ASPX Code:

<ig:WebHierarchicalDataGrid ID="test" InitialDataBindDepth="1" runat="server" AutoGenerateColumns="false"
AutoGenerateBands="false" ViewStateMode="Enabled" DataKeyFields="ModuleID"
OnRowUpdating="Module_RowUpdating" Width="100%" OnItemCommand="test_ItemCommand" >
<ClientEvents Initialize="InitializHandler" Click="ClickHandler" />
<ExpandCollapseAnimation SlideOpenDirection="Auto" SlideOpenDuration="300" SlideCloseDirection="Auto"
SlideCloseDuration="300" />
<Columns>
<ig:BoundDataField DataFieldName="RolePermissionID" Key="RolePermissionID" Hidden="true" />
<ig:BoundDataField DataFieldName="ModuleID" Key="ModuleID" Width="100px" />
<ig:BoundDataField DataFieldName="ModuleName" Key="ModuleName" Header-Text="Module Name" />
<%-- <ig:TemplateDataField Key="tdfPermissionView">
<ItemTemplate>
<asp:CheckBox ID="chkModulePermissionView" runat="server" Checked='<%# Eval("PermissionView") %>' />
</ItemTemplate>
</ig:TemplateDataField>--%>

<ig:BoundCheckBoxField DataFieldName="PermissionView" Key="PermissionView" Header-Text="View" />
<ig:BoundCheckBoxField DataFieldName="PermissionAdd" Key="PermissionAdd" Header-Text="Add" />
<ig:BoundCheckBoxField DataFieldName="PermissionEdit" Key="PermissionEdit" Header-Text="Edit" />
<ig:BoundCheckBoxField DataFieldName="PermissionDelete" Key="PermissionDelete" Header-Text="Delete" />

</Columns>
<Behaviors>
<ig:EditingCore BatchUpdating="true" AutoCRUD="false">
<Behaviors>
<ig:CellEditing>

</ig:CellEditing>

</Behaviors>
</ig:EditingCore>
</Behaviors>

<Bands>
<ig:Band DataMember="Tabs" Key="Tabs" AutoGenerateColumns="false" DataKeyFields="ModuleTabID" Width="100%" OnRowUpdating="Tab_RowUpdating">
<Columns>
<ig:BoundDataField DataFieldName="RolePermissionID" Key="RolePermissionID" Hidden="true" />
<ig:BoundDataField DataFieldName="ModuleTabID" Key="ModuleTabID" />
<ig:BoundDataField DataFieldName="TabName" Key="TabName" Header-Text="Tab Name" />
<%--<ig:TemplateDataField Key="CheckBox">
<Header Text="CheckBox" />
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("PermissionView") %>' />
</ItemTemplate>
</ig:TemplateDataField>--%>
<ig:BoundCheckBoxField DataFieldName="PermissionView" Key="PermissionView" Header-Text="View" />
<ig:BoundCheckBoxField DataFieldName="PermissionAdd" Key="PermissionAdd" Header-Text="Add" />
<ig:BoundCheckBoxField DataFieldName="PermissionEdit" Key="PermissionEdit" Header-Text="Edit" />
<ig:BoundCheckBoxField DataFieldName="PermissionDelete" Key="PermissionDelete" Header-Text="Delete" />

</Columns>
<Behaviors>
<ig:EditingCore>
<Behaviors>
<ig:CellEditing></ig:CellEditing>
</Behaviors>
</ig:EditingCore>
</Behaviors>

<Bands>
<ig:Band DataMember="Tablets" Key="Tablets" AutoGenerateColumns="false" DataKeyFields="ModuleTabTabletID, ModuleTabID" Width="100%" OnRowUpdating="Tablet_RowUpdating">
<Columns>
<ig:BoundDataField DataFieldName="RolePermissionID" Key="RolePermissionID" Hidden="true" />
<ig:BoundDataField DataFieldName="ModuleTabTabletID" Key="ModuleTabTabletID" />
<ig:BoundDataField DataFieldName="TabletName" Key="TabletName" Header-Text="Tablet Name" />
<ig:BoundCheckBoxField DataFieldName="PermissionView" Key="PermissionView" Header-Text="View" />
<ig:BoundCheckBoxField DataFieldName="PermissionAdd" Key="PermissionAdd" Header-Text="Add" />
<ig:BoundCheckBoxField DataFieldName="PermissionEdit" Key="PermissionEdit" Header-Text="Edit" />
<ig:BoundCheckBoxField DataFieldName="PermissionDelete" Key="PermissionDelete" Header-Text="Delete" />

</Columns>
<Behaviors>
<ig:EditingCore>
<Behaviors>
<ig:CellEditing></ig:CellEditing>
</Behaviors>
</ig:EditingCore>
</Behaviors>

</ig:Band>
</Bands>
</ig:Band>
</Bands>

</ig:WebHierarchicalDataGrid>

JS Code:

var whdg;

function InitializHandler(sender, args) {
whdg = sender;
}

var isChecked = false;

// Loop through all child island's rows check either uncheck the checkbox according to parent row checkbox state.
function ClickHandler(sender, args) {

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

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

var childGrids = whdg.get_rows().get_row(rowIndex).get_rowIslands();

alert(childGrids[0].get_rows().get_length());

for (var j = 0; j < childGrids[0].get_rows().get_length() ; j++) {

if (isChecked) {

childGrids[0].get_rows()
.get_row(j).get_cell(3)
.get_element()
.children[0].checked = false;
}


}
}

C# Code:

protected void Tab_RowUpdating(object sender, RowUpdatingEventArgs e)
{
RolePermission rolePermission = new RolePermission();

if (e.Values["RolePermissionID"] == null)
rolePermission.RolePermissionID = 0;
else
rolePermission.RolePermissionID = e.Values["RolePermissionID"].ToString().ToInt32();
rolePermission.RoleID = hdnID.Value.ToInt32(); ;
rolePermission.ModuleTabID = e.Values["ModuleTabID"].ToString().ToInt32();
rolePermission.PermissionView = Convert.ToBoolean(e.Values["PermissionView"]);
rolePermission.PermissionAdd = Convert.ToBoolean(e.Values["PermissionAdd"]);
rolePermission.PermissionEdit = Convert.ToBoolean(e.Values["PermissionEdit"]);
rolePermission.PermissionDelete = Convert.ToBoolean(e.Values["PermissionDelete"]);

_roleManagement.SaveRolePermissionOtherTab(rolePermission);


}



Parents Reply Children
No Data