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" />
</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);
}
I will wait for the public release but if there is anything urgent I will let you know.
Thanks again for your help/support.
Regards
Shoaib
Hello Muhammad,
receiving the fix earlier means receiving a private build. A private build differs from an official public build that it has passed automated testes and manual functional testing has been done only for the given issue (in your case this is the boundCheckBoxFields returning wrong values across postbacks). If you go for this build we will be able to provide it next week.
Please let me know your decision.
Hi,
Thanks for the code sample. I will let you know if I am having any difficulty in applying it.
Below are the answers for your questions;
1) Yes, we have a demo for user acceptance testing on Nov 18 and if nothing new comes up then probably we have to deploy it after 2 weeks.
2) No, we don't want untested build.
3) The issue is everywhere, I mean it is happening in our development and staging environment.
Please find my response below:
1) One small request, can you please provide me a code sample to access BoundCheckBoxField in javascript considering my gird (shared earlier). I have a little weird requirement that if the checkbox in parent grid (level 1) is selected then then all the child should be unselected and if the child is selected then parent should be unselected. For all three hierarchical datatables my column structure is same.
1. As mentioned you need to attach to the Editing behavior cellValueChanged client side event, and there you can execute this logic to achieve the desired:
function WebGrid_CellValueChanged(sender, eventArgs) { var cell = eventArgs.get_cell();
if (eventArgs.get_cell().get_value()) { var childGrid = childGrid = cell.get_row().get_rowIslands()[0]; for (var i = 0; i < childGrid.get_rows().get_length() ; i++) { childGrid.get_rows().get_row(i).get_cellByColumnKey(cell.get_column().get_key()).set_value(false); } }
if (!eventArgs.get_cell().get_value()) { var childGrid = childGrid = cell.get_row().get_rowIslands()[0]; for (var i = 0; i < childGrid.get_rows().get_length() ; i++) { childGrid.get_rows().get_row(i).get_cellByColumnKey(cell.get_column().get_key()).set_value(true); } } }
Please find a sample attached demonstrating this approach.
2) Is it possible that can I have the hot fix or some thing like earlier.
In order to escalate the issue and provide you with a fix as quickly as possible, you need to answers the following questions:1) Do you have a deadline of your project? And what is it?2) Do you want an untested build when it is available?3) Is this issue in the production environment?
Thanks for the reply. Is it possible that can I have the hot fix or some thing like earlier.
One small request, can you please provide me a code sample to access BoundCheckBoxField in javascript considering my gird (shared earlier).
I have a little weird requirement that if the checkbox in parent grid (level 1) is selected then then all the child should be unselected and if the child is selected then parent should be unselected. For all three hierarchical datatables my column structure is same.