﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><pubDate>Tue, 27 Sep 2011 02:51:36 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui', 'sans-serif'; color: #1f497d; font-size: 9pt"&gt;All codes related to the &lt;em&gt;assignment of data source&lt;/em&gt; to the WebGrid component should be placed in the &lt;em&gt;InitializeDataSource&lt;/em&gt; server-side event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui', 'sans-serif'; color: #1f497d; font-size: 9pt"&gt;After WebGrid has successfully binded its DataSource which defined using e.DataSource. In the &lt;em&gt;PrepareDataBinding&lt;/em&gt; server-side event, developers can conveniently &lt;em&gt;populate all the columns structure&lt;/em&gt;. There are many cases that developers often forgot to place all "object creation" codes under !IsPostBack condition, so please remember to place WebGrid1.RetrieveStructure() or WebGrid1.RetrieveHierarchicalStructure() under !IsPostBack condition. There are cases such as users has utilized resizing columns, sorting and grouping features and invoked PostBack to the server, but after the PostBack all the features applied are overrided back to the first configuration erasing all features that have been applied.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui', 'sans-serif'; color: #1f497d; font-size: 9pt"&gt;The snippet code below shows the modified version of BatchUpdate_CustomObjectUpdate.aspx.cs file (the file is attached on my previous post). In the modified version columns are created dynamically in PrepareDataBinding server-side event using following code.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    if (!IsPostBack)
    {
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("CustomerID", "CustomerID", "CustomerID"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("CompanyName", "CompanyName", "CompanyName"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("ContactName", "ContactName", "ContactName"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("ContactTitle", "ContactTitle", "ContactTitle"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("Address", "Address", "Address"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("City", "City", "City"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("Region", "Region", "Region"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("PostalCode", "PostalCode", "PostalCode"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("Country", "Country", "Country"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("Phone", "Phone", "Phone"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("Fax", "Fax", "Fax"));
        WebGrid1.RootTable.Columns.Add(new WebGridColumn("Orders", "Orders", "Orders"));
        WebGrid1.RootTable.DataKeyField = "CustomerID";            
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui', 'sans-serif'; color: #1f497d; font-size: 9pt"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><pubDate>Thu, 22 Sep 2011 03:19:30 GMT</pubDate><dc:creator>gavin</dc:creator><description>&lt;p&gt;&lt;span style="font-size: 11pt"&gt;Hello Yudi , &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp; Thank you for your sample and help . The sample you provided worked smoothly . But I think I do not explain my problem clearly .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;    &lt;span style="font-size: 11pt"&gt;In my project , if I create the columns of WebGrid in the foreground program , the problem I said will not appear . However , if I dynamically create the columns in the&amp;nbsp;method named "WG1_InitializeDataSource" , there will be&amp;nbsp;some problems&amp;nbsp;. A&lt;span style="color: #000000; font-size: 11pt"&gt;fter invoking the OnBatchUpdate server-side event , it will invoke the method named "WG1_InitializeDataSource" again . Then the misaligned column will occur .&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;span style="font-size: 11pt"&gt;Can you help me to solve this problem ? Thanks a lot !&lt;/span&gt;&lt;/p&gt;</description></item><item><title>The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><pubDate>Wed, 21 Sep 2011 17:07:14 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;I enclosed my simple sample as attachment.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Please have the sample tested on your end and let us know if the problem still occurs. Should you find anything that I missed during my attempt to reproduce the issue, please feel free to modify the sample and send it back to us to be investigated further.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;For your information, I’m using WebGrid 7 build 432 and WebUI.NET Framework 3.0 build 773.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><pubDate>Wed, 21 Sep 2011 03:53:06 GMT</pubDate><dc:creator>gavin</dc:creator><description>&lt;p&gt;&lt;span style="font-size: 11pt"&gt;Hi Yudi ,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp; Thank you for your reply ! My latest build version of WebGrid&amp;nbsp;is 7.0.7200.431 and the latest build version of WebUI is 3.0.5000.1 .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;   &lt;span style="font-size: 11pt"&gt;Can you give me that&amp;nbsp;&lt;span style="color: #000000"&gt; running simple sample of batch update ?  I will be very grateful !&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><pubDate>Tue, 20 Sep 2011 15:50:12 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;I tried to reproduce the problem by creating a running simple sample of batch update enabled WebGrid but my efforts were not successful – everything worked smoothly and I was unable to reproduce the misaligned column after invoking the OnBatchUpdate server-side event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;Could you please confirm whether you are using the latest build version of WebGrid 7 and WebUI.NET Framework 3?&lt;/span&gt;&lt;/p&gt;</description></item><item><title>The columns of webgrid will huddle after using the BatchUpdate method ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/The-columns-of-webgrid-will-huddle-after-using-the-BatchUpdate-method-/</link><pubDate>Tue, 20 Sep 2011 04:07:58 GMT</pubDate><dc:creator>gavin</dc:creator><description>&lt;p&gt;&lt;span style="font-size: 11pt"&gt;Hi , &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp; I meet a problem When I use BatchUpdate method . Before I use this method , my webgrid display normal . But After&amp;nbsp;my program execute&amp;nbsp;the BatchUpdate method , the columns of webgrid are huddled , like the pictures in the attchment file .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;   &lt;span style="font-size: 11pt"&gt;The following &amp;nbsp;code&amp;nbsp; is the key code of my foreground program&amp;nbsp;.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;ISWebGrid:WebGrid ID="WG1" runat="server" UseDefaultStyle="True" DefaultStyleMode="Win7"
                Height="100%" OnInitializeDataSource="WG1_InitializeDataSource" OnBatchUpdate="WG1_BatchUpdate"
                OnInitializeRow="WG1_InitializeRow"&amp;gt;
                &amp;lt;RootTable GridLineStyle="NotSet" DataKeyField="ModuleGuid"&amp;gt;
                    &amp;lt;Columns&amp;gt;
                    &amp;lt;/Columns&amp;gt;
                &amp;lt;/RootTable&amp;gt;
                &amp;lt;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"&amp;gt;
                    &amp;lt;ClientSideEvents OnAfterInitialize="WG1_OnAfterInitialize" OnRowContextMenu="WG1_OnRowContextMenu"
                        OnEnterEditMode="WG1_OnEnterEditMode" OnAfterExitEditMode="WG1_OnAfterExitEditMode" /&amp;gt;
                    &amp;lt;TextSettings Language="UseCustom" UseLanguage="zh-CN"&amp;gt;
                    &amp;lt;/TextSettings&amp;gt;
                    &amp;lt;HeaderStyle CssClass="WG-Header" /&amp;gt;
                    &amp;lt;RowHeaderStyle CssClass="WG-RH"&amp;gt;
                    &amp;lt;/RowHeaderStyle&amp;gt;
                    &amp;lt;RowStyle CssClass="WG-Row"&amp;gt;&amp;lt;/RowStyle&amp;gt;
                    &amp;lt;AlternatingRowStyle CssClass="WG-AR" /&amp;gt;
                    &amp;lt;SelectedRowStyle CssClass="WG-SR" /&amp;gt;
                    &amp;lt;LostFocusRowStyle CssClass="WG-LFR"&amp;gt;
                    &amp;lt;/LostFocusRowStyle&amp;gt;
                    &amp;lt;EditTextboxStyle CssClass="WG7W-ET"&amp;gt;
                    &amp;lt;/EditTextboxStyle&amp;gt;
                    &amp;lt;ClientSideEvents OnAfterInitialize="WG1_OnAfterInitialize" OnRowContextMenu="WG1_OnRowContextMenu"
                        OnCheckBoxClick="WG1_OnCheckBoxClick" /&amp;gt;
                &amp;lt;/LayoutSettings&amp;gt;
            &amp;lt;/ISWebGrid:WebGrid&amp;gt;&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp; The following code is the key code of my background program .&lt;/span&gt;&lt;/p&gt;&lt;pre&gt; protected void WG1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
 {
&lt;br /&gt;&lt;br /&gt;       string IsTop = ConfigurationManager.AppSettings["IsTop"];&lt;br /&gt;        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 &amp;lt; chkRoleList.Items.Count; i&amp;#43;&amp;#43;)
            {
                if (!chkRoleList.Items[i].Selected)
                {
                    RemoveCount&amp;#43;&amp;#43;;
                    continue;
                }
                ChkRoleNameLst &amp;#43;= chkRoleList.Items[i].Text &amp;#43; ";";
                ChkRoleGuidLst &amp;#43;= chkRoleList.Items[i].Value &amp;#43; ";";

            }

            string[] chkRoleName = ChkRoleNameLst.TrimEnd(';').Split(';');
            string[] chkRoleGuid = ChkRoleGuidLst.TrimEnd(';').Split(';');

            if (ChkRoleGuidLst != "")
            {
                for (int j = 0; j &amp;lt; chkRoleGuid.Length; j&amp;#43;&amp;#43;)
                {
                    wgCol0 = new WebGridColumn();
                    wgCol0.Caption = chkRoleName[j] &amp;#43; "&amp;lt;input type=\"checkbox\" onclick=\"SelectAllColumn(this)\" name=\"" &amp;#43; j &amp;#43; "_chk_" &amp;#43; chkRoleGuid[j] &amp;#43; "\"&amp;gt;";
                    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 = "完全公开" &amp;#43; "&amp;lt;input type=\"checkbox\" onclick=\"SelectAllColumn(this)\" name=\"" &amp;#43; Index &amp;#43; "_chk_完全公开_" &amp;#43; "\"&amp;gt;";
            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=&amp;amp;setType=module&amp;amp;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"];                &lt;br /&gt;                   string ModuleGuidLst = ViewState["ModuleGuidLst"].ToString();
                    DataView dv_module = ModuleRights.getRolesRightV3("public", IsTop, ViewState["RoleFilter"].ToString().Split(';'), out ModuleGuidLst);
                    dv_module.RowFilter = "ModuleGuid='" &amp;#43; ModuleGuid &amp;#43; "'";

                    AppRole OldAppRole = new AppRole(ModuleGuid, dv_module[0]["完全公开"].ToString());

                    AppRole NewAppRole = getChangeValue(rowChanges.Data, ModuleGuid);

                    if ((OldAppRole.AllGK.ToLower() == "true" &amp;amp;&amp;amp; NewAppRole.AllGK == "NoEdit") || (OldAppRole.AllGK.ToLower() == "false" &amp;amp;&amp;amp; NewAppRole.AllGK.ToLower() == "true"))
                    {
                        ModuleRights.ModuleRight_Delete(ModuleGuid, "Role");&lt;br /&gt;                        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");
                            }
                        }
                    }

                }
            }
}&lt;/pre&gt;

&lt;p&gt; &lt;span style="font-size: 11pt"&gt;Anyone can help me ? Thank you very much !&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>