Hello,
I'm using UltraWebGrid 7.2.20072.61 and I'm trying to add a checkbox in the column header (for typical check all functionality). The Problem is that the data I'm using is dynamic in that I've created a Pivot on dates using a stored procedure. What this means is that the columns that I need the checkbox header on could be anywhere in count from 1 to 180 so obviously I can't do this at the design level.
My first several columns are frozen and work great and I have a hidden DataKeyField Column for the userid. The problem comes when I try to cast the next columns as template columns. The cast is failing. I've tried creating a loop in the UltraWebGrid1_InitializeLayout based on the number of columns sent back (past the first five which will always be the same). I've also tried adding templated columns but they just appear after the bound columns and the header (using GridHeaderTemplate class with an InstantiateIn) isn't applied.
All of the samples I've found in the KB are for older versions and do not cover how to add checkbox headers for dynamically created columns.
Does UltraWebGrid 7.2 support this and if so how is this done?
Thanks for any help!
No this example did not resolve the issue.
I took the example that you sent and converted it to run in VS2005. All this does is add a templated column with the header name "templated column" at the beginning of the ultrawebgrid . It does not convert an existing column to a templated column. In fact when I attempt to change the column "Weights" from this example to a templated column in this example I get the original BUG:
Unable to cast object of type 'Infragistics.WebUI.UltraWebGrid.UltraGridColumn' to type 'Infragistics.WebUI.UltraWebGrid.TemplatedColumn'.
After about 6 months of back and forth with Infragistics on this I can only come to the conclusion that there is a bug in Infragistics2.WebUI.UltraWebGrid.v7.2, Version=7.2.20072.61 or that I'm trying to implement a feature that your product was never intended to do. The original goal was to take columns that are added dynamically at run time and create a check all header. They would only be needed on any column after the 5th. Seems like a standard feature that should be supported but the columns are dynamic in that there is a variable number of columns returned that will need that header checkbox depending on the data. Apparently the only way to add a checkbox header is through templated columns which fail the cast. This appears to be a bug.
Unfortunate.
Thanks for responding though.
Hi,
I am following up with you and if the issue was resolved.
Magued
The closest sample that we have to what you are trying to accomplish is:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=4876
The sample doesn't create the columns after you databind. Still you can find and create the Templated columns at runtime. I suggest you also test your solution with a Microsoft GridView.
Unfortunately no. I have to bind to the data and then set the column to a templated column. This is because the payload could have 1 or 100 columns that need to be templated columns so it needs to be cast as a templated column after the bind.
I've attempted to run a loop to create columns based on the column count from the payload and then bind but that results in a group of empty columns in the middle of the webgrid. While the example you've sent works for a static number of columns I need to be able to set every column from say column 5 up to a templated column with a checkbox header.
The error I get is on:
Line 175: Infragistics.WebUI.UltraWebGrid.TemplatedColumn tc = (Infragistics.WebUI.UltraWebGrid.TemplatedColumn)e.Layout.Bands[0].Columns[0];
is:
The reason the cast IS working for you is that you are explicitly setting the column to a templated column in Default2.aspx:
<igtbl:TemplatedColumn Key="" BaseColumnName="C1">
<HeaderTemplate>
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>
</HeaderTemplate>
</igtbl:TemplatedColumn>
I cannot set this column or any column that I need as a templated column at design time because the number of columns returned in the payload is dynamic. It could be one column or 100 columns.