iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi ,
In the webgrid , when I want to select all checkboxs of a column through clicking the checkbox of the column header , I meet a problem . The picture in the attachment file describes this issue .
In the foreground Program , I use the SelfReferencingSettings . When I click the checkbox of the column header to select all checkboxs of this column , the first layer checkboxs can be selected . If a parent row has some child rows , the checkbox of the parent row can be selected , but the checkboxs of these child rows can not be selected .
The following is the key code of the foreground program .
<ISWebGrid:WebGrid ID="WG1" runat="server" UseDefaultStyle="True" DefaultStyleMode="Win7" Height="100%" OnInitializeDataSource="WG1_InitializeDataSource" OnBatchUpdate="WG1_BatchUpdate" > <RootTable GridLineStyle="NotSet" DataKeyField="ModuleGuid"> <SelfReferencingSettings ChildDataMember="ParentModuleCode" Enabled="True" IsTreeViewSelectionMode="false"ExpandColumnMember="ModuleName" ParentDataMember="ModuleCode" /> <Columns> </Columns> </RootTable> <LayoutSettings AllowSorting="Yes" AllowSelectColumns="Yes" AlwaysShowHelpButton="false" AllowEdit="Yes" AllowMultipleSelection="No" AllowColumnFreezing="No" StatusBarVisible="true" AllowBatchUpdate="true" AutoHeight="true" AutoWidth="false" AutoFitColumns="true"AllowGrouping="No" PagingMode="ClassicPaging" PagingLoadMode="Automatic" PagingSize="50"> <ClientSideEvents OnAfterInitialize="WG1_OnAfterInitialize" OnRowContextMenu="WG1_OnRowContextMenu" OnEnterEditMode="WG1_OnEnterEditMode" OnAfterExitEditMode="WG1_OnAfterExitEditMode" /> <TextSettings Language="UseCustom" UseLanguage="zh-CN"> </TextSettings> <HeaderStyle CssClass="WG-Header" /> <RowHeaderStyle CssClass="WG-RH"> </RowHeaderStyle> <RowStyle CssClass="WG-Row"></RowStyle> <AlternatingRowStyle CssClass="WG-AR" /> <SelectedRowStyle CssClass="WG-SR" /> <LostFocusRowStyle CssClass="WG-LFR"> </LostFocusRowStyle> <EditTextboxStyle CssClass="WG7W-ET"> </EditTextboxStyle> <ClientSideEvents OnAfterInitialize="WG1_OnAfterInitialize" OnRowContextMenu="WG1_OnRowContextMenu"OnCheckBoxClick="WG1_OnCheckBoxClick" /> </LayoutSettings> </ISWebGrid:WebGrid>
The following is the key code of creating a column of webgrid .
wgCol0 = new WebGridColumn(); int Index = chkRoleList.Items.Count - RemoveCount; wgCol0.Caption = "完全公开" + "<input type=\"checkbox\" onclick=\"SelectAllColumn(this)\" name=\"" + Index + "_chk_完全公开_" + "\">"; wgCol0.ColumnType = ColumnType.CheckBox; wgCol0.CellStyle.HorizontalAlign = ISNet.WebUI.HorizontalAlign.Center; wgCol0.Name = "完全公开"; wgCol0.EditType = EditType.Checkbox; wgCol0.DataType = "System.Boolean"; wgCol0.Width = 100; wgCol0.IsAutoWidth = false; wgCol0.AllowSorting = Sorting.No; wgCol0.DataMember = "完全公开"; wgCol0.CellStyle.HorizontalAlign = ISNet.WebUI.HorizontalAlign.Center; WG1.RootTable.Columns.Add(wgCol0);
The following is the javascript method of selecting all checkboxs by clicking the checkbox of the column header .
function SelectAllColumn(obj) { var grid = ISGetObject("<%= WG1.ClientID %>"); var index = obj.name.split('_'); var cellIndex = parseInt(index[0]) + 1; for (i = 0; i < grid.TotalLoadedRows; i++) { var row = grid.RootTable.GetRow(i); var cell = row.GetCells()[cellIndex]; if (obj.checked) { cell.SetValue(true, true); } else { var cbxElement = cell.GetElement().childNodes[0]; cbxElement.click(); cbxElement.checked = false; } cell.ActivateEdit(); grid.MarkEdit(); grid.ExitEdit(1, 0, 0); } }
Anyone can help me to solve this issue ? Thanks a lot !
I meet another problem about using SelfReferencingSettings . If the parent node has some childnodes , how can I set to make the childnodes AUTOexpand when page is loading ? Besides that , when I modify some content of the childnode and click the button of Save , how can I set to make the childnode keep expanding ?
Who can help me ? Thanks a lot !
Hello,
It is different from normal scenario. In Flat or normal WebGrid, we have ISRowChecker which will check or uncheck rows when the checkbox header clicked. However, in grouping, hierarchical or even in SelfReference, you might see that the child level is not checked. This is default behaviour. Since this is not a treeview, even though the parent row is checked, the child will not be checked. Our checkbox is only for a flag for the current row. That's why it does not designed for the other level.Same result with your custom checkbox. I think you used logic to check the loaded row. However, it can only be applied for one level (parent).You will need to add additional code to get the selfreference child rows and check them manually.
Regarding the expand in SelfReference, when there is a flypostback request such as sort,refresh, update, etc, WebGrid would collapse the level again. We don't have any property to handle that scenario for now.I suggest you to expand all the row at first load. With this way, it will not get closed.
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { if (e.Row.SelfRefChildren != null) { e.Row.ExpandSelfRefRow(); } }
Regards,Handy
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname