﻿<?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 - How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</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>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Wed, 08 Sep 2010 04:51:35 GMT</pubDate><dc:creator>Eric</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>&lt;p&gt;Hii Glenn,&lt;/p&gt;
&lt;p&gt;Thanks for clarification. Here some comments from my side:&lt;/p&gt;
&lt;p&gt;Two database calls is not an option for two reasons:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;It would be slow. If you make two different calls, the first one only calling a COUNT, there would probably be no big difference, except the call overhead and the actual database counting.&lt;/li&gt;&lt;li&gt;Bad design, risking a crash. If the data changes between the two calls, the result would be undefined or completely wrong.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Yes, calling the db in OnLoad and caching it somehow, like in a member variable, would be an option. I will consider this. Or remove the freezeing altogether.&lt;/p&gt;
&lt;p&gt;But why is PreRender too late? I think this is a design flaw in WebGrid. Before the PreRender event, no data should get rendered to the client. And enabling/disabling column freezing, which can also be done on the client-side, is clearly a rendering issue. Don't you agree with this?&lt;/p&gt;</description></item><item><title>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Wed, 08 Sep 2010 00:44:57 GMT</pubDate><dc:creator>Glayaar</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>In order to enable or disable ColumnFreezing feature, the PreRender event handler will be too late, so I suggest using the PageLoad event which will be invoked earlier.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Based on your description, such scenario will required 2 database request. The first one in the page load will return if the query return any row, using SELECT COUNT, which will only return a scalar value. The second one in the InitializeDataSource will be run if the first query determine there is a data.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Another suggestion is to run the query in the page load and hold the result in a class property. During the initialize data source event handler, instead of requerying the database you will only need to refer to the class property. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;</description></item><item><title>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Tue, 07 Sep 2010 05:24:44 GMT</pubDate><dc:creator>Eric</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>&lt;p&gt;Hi Glenn,&lt;/p&gt;
&lt;p&gt;Thanks for your idea. I didn't try it, because I think it cannot work by design - tell me if I'm wrong. What you are doing here is to enable/disable freezing in Page_Load, depending on whether the filter is set to a value that doesn't return data.&lt;/p&gt;
&lt;p&gt;We don't know if there is data available or not, just by looking at the filter selection. In this hardcoded sample it might work, but what you are doing here would mean to query the database in Page_Load to see if there is data available or not. Is it that what you intended here?&lt;/p&gt;
&lt;p&gt;For me that would mean we have two database requests: one in Page_Load, the other one in grid_InitializeDataSource. One must be enough. Did you want to move this all to the Page_Load event? If yes, then that part is missing. Or did I misunderstand anything?&lt;/p&gt;
&lt;p&gt;Any other ideas?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Eric&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Tue, 07 Sep 2010 04:54:01 GMT</pubDate><dc:creator>Glayaar</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>&lt;p&gt;After further testing using the sample code in &lt;a target="_blank" href="../WebGrid-crash-scrolling-freeze-column-hidden/"&gt;this thread&lt;/a&gt;. You could disable the ColumnFreeezing during page load event. Here is the snippet, only disable the ColumnFreezing if the SelectedValue is C:&lt;/p&gt;&lt;pre&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    if(!Page.IsPostBack)&lt;br /&gt;    {&lt;br /&gt;        ddlChoiceA.Items.Add(new System.Web.UI.WebControls.ListItem("A: all columns", "A"));&lt;br /&gt;		ddlChoiceA.Items.Add(new System.Web.UI.WebControls.ListItem("B: some hidden columns (16-19, 21-22)", "B"));&lt;br /&gt;        ddlChoiceA.Items.Add(new System.Web.UI.WebControls.ListItem("C: no data", "C"));&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;    if (ddlChoiceA.SelectedValue == "C")&lt;br /&gt;        grdResult.LayoutSettings.AllowColumnFreezing = ColumnFreezing.No;&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Mon, 06 Sep 2010 08:00:41 GMT</pubDate><dc:creator>Eric</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>&lt;p&gt;So how would that work in my example?&lt;/p&gt;
&lt;p&gt;Add a dynamic script somehow in PreRender to do that on the client side?&lt;/p&gt;</description></item><item><title>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Mon, 06 Sep 2010 06:37:19 GMT</pubDate><dc:creator>Glayaar</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>&lt;p&gt;Based on my discussion with the developer, the FreezePane must be enabled or disabled in client side event handler. I am still in the process of simulating the scenario in my environment. I will inform you of any discovery I made. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>How to enable / disable freezing depending on data</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-enable-disable-freezing-depending-on-data/</link><pubDate>Fri, 03 Sep 2010 09:41:51 GMT</pubDate><dc:creator>Eric</dc:creator><category>dynamically</category><category>freeze</category><category>crash</category><category>column</category><category>InitializeDataSource</category><category>frozen</category><category>Freeze Pane</category><category>enable</category><category>disable</category><category>scrollable</category><description>&lt;p&gt;There is a related sample in this thread: &lt;a href="http://www.intersoftpt.com/Community/WebGrid/WebGrid-crash-scrolling-freeze-column-hidden/"&gt;http://www.intersoftpt.com/Community/WebGrid/WebGrid-crash-scrolling-freeze-column-hidden/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When I have no data for the grid, I want to hide all columns, create my own dataset add a row and write the text "no data" into this first row's first column. This is done in the InitializeDataSource event.&lt;/p&gt;
&lt;p&gt;In PreRender event I check if there is only this one row with this special text. If yes, I hide all columns (now works after you fixed the crash mentioned in the other thread).&lt;/p&gt;
&lt;p&gt;Problem is now that I cannot dynamically enable/disable the column freezing. For normal display, I want the first column to freeze (not modifiable by user). But when I hide all columns when no data is present, I get the error message "Freeze Pane cannot be activated on this column because it has exceeded the maximum size of scrollable viewport."&lt;/p&gt;
&lt;p&gt;I assume this is because there is nothing to show (message is probably slightly wrong). So I should disable the frozen columns in the PreRender event somehow. I couldn't get that working. Or leave freezing away in aspx page and enable it for normal data.&lt;/p&gt;
&lt;p&gt;In grid's LayoutSettings I have:&lt;/p&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;
&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px; color: #a31515"&gt;&lt;span style="font-size: 13px; color: #a31515"&gt;FreezePaneSettings&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;AbsoluteScrolling&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;="true"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;ActiveFrozenColumns&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;="1"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;MaxFrozenColumns&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;="1"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;ShowSplitterLine&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;="False"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;/&amp;gt; 

&lt;/span&gt;&lt;/span&gt;In PreRender I tried to disable these values without success. I also tried leaving the above tag away and adding these values in PreRender. 

&lt;p&gt;I also tried to set/change the value &lt;span style="font-size: 13px"&gt;grdResult.LayoutSettings.AllowColumnFreezing&lt;/span&gt;. But that caused WebGrid to crash in some JavaScript.&lt;/p&gt;
&lt;p&gt;How do I disable/enable column freezing depending on the data I have?&lt;/p&gt;</description></item></channel></rss>