How to enable / disable freezing depending on data

6 replies. Last post: September 8, 2010 4:51 AM by Eric
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Eric Member

There is a related sample in this thread: http://www.intersoftpt.com/Community/WebGrid/WebGrid-crash-scrolling-freeze-column-hidden/

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.

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).

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."

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.

In grid's LayoutSettings I have:

<FreezePaneSettings AbsoluteScrolling="true" ActiveFrozenColumns="1" MaxFrozenColumns="1" ShowSplitterLine="False" /> In PreRender I tried to disable these values without success. I also tried leaving the above tag away and adding these values in PreRender.

I also tried to set/change the value grdResult.LayoutSettings.AllowColumnFreezing. But that caused WebGrid to crash in some JavaScript.

How do I disable/enable column freezing depending on the data I have?

All times are GMT -5. The time now is 12:52 AM.
Previous Next