Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
User control in templated columns (sort problem, bind problem, etc.)
posted

I have been trying to create my own grid column class that contains some custom checkboxes (three state) and one on the header that checks all the checkboxes in the grid. Since I want this encapsulated into a class I can't just use the EditorControlID approach.

What I did is use a TemplatedColumn and set the templates for Header and Cell. My first problem is that I couldn't properly link the value of my custom control with the one in the datasource. I ended up using the value from CellItem.Value to initialize the editor control and the OnChange event for the control to update the CellItem.Value. (I am not sure if this is the way, can you please advise?)

Then I noticed that since I set the HeaderTemplate, I had no filter/sort indicators on the column. I solved it rather ugly by using reflection to execute  SortIndicatorHTMLCode and FilterImageHTMLCode. (also, please tell me what is the better way to do this).

The major problem that I am facing now and I could find no solution for is sorting. If I sort by any column (including itself) the other columns sort correctly, but the values for the templated column remain unchanged. I've reproduced it with a normal templated column, with bound normal checkboxes.

The code is simple: a DataTable with an int and a bool column is bound as the DataSource for the grid in Page_Load. Then the columns are defined in the aspx:

 

 

 

<

 

igtbl:TemplatedColumn>

 

<CellTemplate>

 

<asp:CheckBox runat="server" Checked='<%#Eval("Bool") %>' />

 

</CellTemplate>

 

</igtbl:TemplatedColumn>

 

 

 

 

<igtbl:UltraGridColumn BaseColumnName="Number" />

<igtbl:UltraGridColumn BaseColumnName="Bool" Type=CheckBox />

All columns appear correctly on load, but when sorting by any of the  columns, only the last two show any change.

Please help me with this, as I have been trying the better part of the day to solve this and had no success. I am using Infragistics Web 9.1. Thank you!

Oh, also I couldn't get the values of the column to be displayed in the filter dropdown... :(