The columns of webgrid will huddle after using the BatchUpdate method ?

5 replies. Last post: September 27, 2011 2:52 AM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
xu guochunMember

Hi ,

   I meet a problem When I use BatchUpdate method . Before I use this method , my webgrid display normal . But After my program execute the BatchUpdate method , the columns of webgrid are huddled , like the pictures in the attchment file .

   The following  code  is the key code of my foreground program .

<ISWebGrid:WebGrid ID="WG1" runat="server" UseDefaultStyle="True" DefaultStyleMode="Win7"
                Height="100%" OnInitializeDataSource="WG1_InitializeDataSource" OnBatchUpdate="WG1_BatchUpdate"
                OnInitializeRow="WG1_InitializeRow">
                <RootTable GridLineStyle="NotSet" DataKeyField="ModuleGuid">
                    <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 code is the key code of my background program .

 protected void WG1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
 {


string IsTop = ConfigurationManager.AppSettings["IsTop"];
string ModuleGuidLst = ""; DataView dv_module = ModuleRights.getRolesRightV3(ViewState["ModuleCode"].ToString(), "public", IsTop, dropShowType.SelectedItem.Value, ViewState["RoleFilter"].ToString().Split(';'), out ModuleGuidLst); ViewState["ModuleGuidLst"] = ModuleGuidLst; InitWG(); e.DataSource = dv_module; this.WriteAjaxMessage("InitMenu();"); } private void InitWG() { WG1.RootTable.Columns.Clear(); WebGridColumn wgCol0 = new WebGridColumn(); wgCol0.Name = "ModuleName"; wgCol0.ColumnType = ColumnType.Template; wgCol0.CellTemplate = new CellTemplate(new Control()); wgCol0.Caption = "模块名称"; wgCol0.EditType = EditType.NoEdit; wgCol0.Width = 100; wgCol0.AllowSorting = Sorting.No; WG1.RootTable.Columns.Add(wgCol0); string ChkRoleGuidLst = ""; string ChkRoleNameLst = ""; int RemoveCount = 0; for (int i = 0; i < chkRoleList.Items.Count; i++) { if (!chkRoleList.Items[i].Selected) { RemoveCount++; continue; } ChkRoleNameLst += chkRoleList.Items[i].Text + ";"; ChkRoleGuidLst += chkRoleList.Items[i].Value + ";"; } string[] chkRoleName = ChkRoleNameLst.TrimEnd(';').Split(';'); string[] chkRoleGuid = ChkRoleGuidLst.TrimEnd(';').Split(';'); if (ChkRoleGuidLst != "") { for (int j = 0; j < chkRoleGuid.Length; j++) { wgCol0 = new WebGridColumn(); wgCol0.Caption = chkRoleName[j] + "<input type=\"checkbox\" onclick=\"SelectAllColumn(this)\" name=\"" + j + "_chk_" + chkRoleGuid[j] + "\">"; wgCol0.ColumnType = ColumnType.CheckBox; wgCol0.EditType = EditType.Checkbox; wgCol0.DataType = "System.Boolean"; wgCol0.Width = 120; wgCol0.IsAutoWidth = false; wgCol0.AllowSorting = Sorting.No; wgCol0.DataMember = chkRoleGuid[j]; WG1.RootTable.Columns.Add(wgCol0); } } 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 = "完全公开"; WG1.RootTable.Columns.Add(wgCol0); wgCol0 = new WebGridColumn(); wgCol0.Caption = "高级设置"; wgCol0.Name = "Seeting"; wgCol0.Width = 60; wgCol0.IsAutoWidth = false; wgCol0.HyperlinkDisplayText = " 高级设置"; wgCol0.CellStyle.HorizontalAlign = ISNet.WebUI.HorizontalAlign.Center; wgCol0.ColumnType = ColumnType.HyperLink; wgCol0.HyperlinkTarget = HyperlinkTarget.Custom; wgCol0.HyperlinkFormatString = "javascript:doSelectRightPage('Pages/DlgRight/Setting_AllowTo_All.aspx?baseOuGuid=&setType=module&argsGuid=');"; WG1.RootTable.Columns.Add(wgCol0); } protected void WG1_BatchUpdate(object sender, BatchUpdateEventArgs e) { string ModuleGuid = ""; foreach (WebGridRowChanges rowChanges in e.PendingChanges) { if (rowChanges.RowState == RowState.Modified) { ModuleGuid = rowChanges.KeyValue.ToString(); string IsTop = ConfigurationManager.AppSettings["IsTop"];
string ModuleGuidLst = ViewState["ModuleGuidLst"].ToString(); DataView dv_module = ModuleRights.getRolesRightV3("public", IsTop, ViewState["RoleFilter"].ToString().Split(';'), out ModuleGuidLst); dv_module.RowFilter = "ModuleGuid='" + ModuleGuid + "'"; AppRole OldAppRole = new AppRole(ModuleGuid, dv_module[0]["完全公开"].ToString()); AppRole NewAppRole = getChangeValue(rowChanges.Data, ModuleGuid); if ((OldAppRole.AllGK.ToLower() == "true" && NewAppRole.AllGK == "NoEdit") || (OldAppRole.AllGK.ToLower() == "false" && NewAppRole.AllGK.ToLower() == "true")) { ModuleRights.ModuleRight_Delete(ModuleGuid, "Role");
ModuleRights.ModuleRight_Insert(ModuleGuid, "All", "Role"); } else { ModuleRights.ModuleRight_Delete(ModuleGuid, "All", "Role"); foreach (WebGridCellData cellData in rowChanges.Data) { if (Convert.ToBoolean(cellData.NewValue) == true) { ModuleRights.ModuleRight_Delete(ModuleGuid, "All", "Role"); ModuleRights.ModuleRight_Insert(ModuleGuid, cellData.Column.DataMember, "Role"); } else { ModuleRights.ModuleRight_Delete(ModuleGuid, cellData.Column.DataMember, "Role"); } } } } } }

 Anyone can help me ? Thank you very much !

2 attachments
All times are GMT -5. The time now is 11:15 AM.
Previous Next