﻿<?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 - WebGrid (6.0) Template Column Not Rendered Upon Load</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-60-Template-Column-Not-Rendered-Upon-Load/</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>WebGrid (6.0) Template Column Not Rendered Upon Load</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-60-Template-Column-Not-Rendered-Upon-Load/</link><pubDate>Tue, 25 Aug 2009 08:57:27 GMT</pubDate><dc:creator>PRISMAY</dc:creator><category>WebGrid 6.0 Template Column Rendering</category><description>&lt;p&gt;I've verified that the key field does get destroyed and that restoring it does work.  So the basic solution is this:&lt;/p&gt;&lt;pre&gt;    // remember this since the call to RetrieveStructure()
    // destroys it. So does the call to LoadTablesStructureFromXml
    // in our LoadGridUserLayout custom method
    string strKeyField = this.KeyField;

    // retrieve the underlying structure
    this.RetrieveStructure();

    // load, if any, the saved grid layout from
    // the database
    LoadGridUserLayout();

    // now restore the key field
    this.RootTable.DataKeyField = strKeyField;
&lt;/pre&gt;
&lt;p&gt;Note that the KeyField property is our custom property which returns this.RootTable.DataKeyField.&lt;/p&gt;</description></item><item><title>WebGrid (6.0) Template Column Not Rendered Upon Load</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-60-Template-Column-Not-Rendered-Upon-Load/</link><pubDate>Mon, 24 Aug 2009 23:09:54 GMT</pubDate><dc:creator>technical@intersoftpt.com</dc:creator><category>WebGrid 6.0 Template Column Rendering</category><description>&lt;p&gt;Yousif,&lt;/p&gt;
&lt;p&gt;Yes, calling RetrieveStructure will override all existing table structure and definition. I'm glad to hear that you figure out the solution.&lt;/p&gt;
&lt;p&gt;Would you mind to set your own post as answer by clicking on "Mark as answer"? This will enable other users to recognize your thread as answered.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;</description></item><item><title>WebGrid (6.0) Template Column Not Rendered Upon Load</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-60-Template-Column-Not-Rendered-Upon-Load/</link><pubDate>Mon, 24 Aug 2009 12:24:36 GMT</pubDate><dc:creator>PRISMAY</dc:creator><category>WebGrid 6.0 Template Column Rendering</category><description>&lt;p&gt;I believe I've found the problem.  The call to RetrieveStructure() destroys the RootTable.DataKeyField property.  I just have to set it back after calling RetrieveStructure().&lt;/p&gt;</description></item><item><title>WebGrid (6.0) Template Column Not Rendered Upon Load</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-60-Template-Column-Not-Rendered-Upon-Load/</link><pubDate>Mon, 24 Aug 2009 10:14:19 GMT</pubDate><dc:creator>PRISMAY</dc:creator><category>WebGrid 6.0 Template Column Rendering</category><description>&lt;p&gt;Our custom grid has a custom check box in a Template type column.  It's always the first column and always on the grid.  It's strange as it does not render, even though the code is created, when the grid is first loaded.  Once any post back is done via refresh grid data, sorting, grouping, etc. the check box is then rendered.  It makes no sense and I'm not sure what I'm missing.  Below are snippets that of our code:&lt;/p&gt;&lt;pre&gt;        public override bool OnPrepareDataBinding(object dataSource)
        {
            if (Page != null)
            {
                bool bFirstFormat = false;

                if (!Page.IsPostBack)
                {
                    // retrieve the underlying structure
                    this.RetrieveStructure();

                    // load, if any, the saved grid layout from
                    // the database
                    LoadGridPreferences();

                    // if it's not an InterSoft post back
                    if (!this.IsFlyPostBack)
                    {
                        // and we have no layout loaded from the db
                        if (!HaveUserLayout)
                        {
                            // then create our columns structure
                            CreateColumnStructure(dataSource);

                            // this flag tells us we're loading the grid with the
                            // default formatting set from the database, i.e., the
                            // user has not made any changes that were saved/loaded
                            // from the db.
                            bFirstFormat = true;
                        }
                    }
                }

                FormatGrid(dataSource, bFirstFormat);
            }

            return base.OnPrepareDataBinding(dataSource);
        }&lt;/pre&gt;
&lt;p&gt;The CreateColumnStructure does this to create the check box column:&lt;/p&gt;&lt;span style="font-size: 10pt"&gt;&lt;pre&gt;...
    this.Columns.Clear();

    // Add the row checker column...
    int iAddedAt = AddTemplateColumn(null);
...
    ClearCachedDataSource();

    return;
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;/span&gt;And all AddTemplateColumn does is this: 
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;        public int AddTemplateColumn(string ColumnName)
        {
            ISNet.WebUI.WebGrid.WebGridColumn oCol = new ISNet.WebUI.WebGrid.WebGridColumn(ColumnName,ColumnName,ColumnName);
            oCol.ColumnType = ISNet.WebUI.WebGrid.ColumnType.Template;

            return this.Columns.Add(oCol);
        }
&lt;/pre&gt;
&lt;p&gt;Once the columns are created, then we have a separate process that formats them.  We read info about the default grid layout from the database and set it up based on the returned info.  Whatever the case through, the check box columns always get created since this column is  not bound.  The code below gets hit regardless of whether the request is an update or not, so this is why I don't understand why it doesn't get rendered.&lt;/p&gt;&lt;pre&gt;...
    // format the row checker column which is always the first one
    int iColIdx = 0;

    // remove and recreate the check box column&lt;br /&gt;    // note that I'm only doing the RemoveAt/Insert because of this&lt;br /&gt;    // rendering problem which I thought this may resolve, but it did not&lt;br /&gt;    // normally I would not have these two lines
    this.Columns.RemoveAt(iColIdx);
    this.Columns.Insert(iColIdx,new ISNet.WebUI.WebGrid.WebGridColumn());

    this.Columns[iColIdx].ColumnType = ISNet.WebUI.WebGrid.ColumnType.Template;
    this.Columns[iColIdx].EditType = ISNet.WebUI.WebGrid.EditType.NoEdit;
    this.Columns[iColIdx].IsRowChecker = false;
    this.Columns[iColIdx].ShowInSelectColumns = ISNet.WebUI.WebGrid.SelectColumns.No;
    this.Columns[iColIdx].Bound = false;

    PrismGridViewCheckBoxColumn cbc = new PrismGridViewCheckBoxColumn();

    // set our custom properties&lt;br /&gt;    cbc.HasClientCheckBoxOnClick        = this.HasClientCheckBoxOnClick;
    cbc.ParentClientId                  = this.ID;
    cbc.ClientCheckBoxOnClick           = this.ClientCheckBoxOnClick;
...
    this.Columns[iColIdx].CellTemplate = cbc;
    this.Columns[iColIdx].IsAutoWidth = false;
    this.Columns[iColIdx].Width = Unit.Pixel(20);
    this.Columns[iColIdx].CellStyle.Width = Unit.Pixel(20);
    this.Columns[iColIdx].CellStyle.HorizontalAlign = ISNet.WebUI.HorizontalAlign.Center;
    this.Columns[iColIdx].CellStyle.VerticalAlign = ISNet.WebUI.VerticalAlign.Middle;
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The attached images show the intitial load of the grid with the default and saved db layouts as well as both after the Refresh grid data is hit.  Notice the check boxes are not there in the initial load but there after the post back.  Any help would be greatly appreciated.  Thank you.&lt;/p&gt;
&lt;p&gt; Please let me know if additional information is needed.  We really need to get this fixed ASAP please.&lt;/p&gt;
&lt;p&gt;Also, as a side note and one other issue related here is if we don't call "&lt;span style="font-size: 10pt" color="#0000ff"&gt;&lt;span style="font-size: 10pt" color="#0000ff"&gt;&lt;span style="font-size: 10pt"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt"&gt;&lt;span style="font-size: 10pt"&gt;.RetrieveStructure();" &lt;/span&gt;&lt;/span&gt;we get JavaScript errors all over the place on post backs after we load the layout from the database.  These are internal errors to the WebGrid, e.g., "&lt;span style="font-size: 10pt" color="#0000ff"&gt;&lt;span style="font-size: 10pt" color="#0000ff"&gt;&lt;span style="font-size: 10pt"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; vec863 =vad719.replace(/[&amp;amp;]/g,&lt;span color="#a31515"&gt;&lt;span color="#a31515"&gt;"%26"&lt;/span&gt;&lt;/span&gt;);"&lt;/span&gt; and so on.&lt;/p&gt;</description></item></channel></rss>