Sep 01, 2010, 4:48 PM
How can I determine a gridpanel column's width and position and whether it is hidden.
If a User hides, moves or resizes a gridpanel column, I need to capture that information in a DataTable. I am using the following code:
1. Column A, Column B and Column C are added to grid at positions 0, 1 and 2 respectively. Each column is 120px wide. All columns are visible.
2. User hides Column B.
3. User drags/moves Column C to position 0. So Column A is now at position "1". Column B is at position "2".
4. User resizes Column A to be 200px.
What I get from the above code is:
int colPosition = 0;
foreach (Ext.Net.Column col in grdResults.ColumnModel.Columns)
{
DataRow drow = dtbl.NewRow();
drow.BeginEdit();
drow.SetField<Int16>("Hidden", (short)(col.Hidden == true ? 1 : 0));
drow.SetField<int>("Width", (int)col.Width.Value);
drow.SetField<int>("Position", colPosition);
colPosition += 1;
drow.EndEdit();
dtbl.Rows.Add(drow);
}
However, col.Hidden and col.Width are returning the original values used to render the grid. That is, they are not reflecting the UI appearance of the grid. As an example:1. Column A, Column B and Column C are added to grid at positions 0, 1 and 2 respectively. Each column is 120px wide. All columns are visible.
2. User hides Column B.
3. User drags/moves Column C to position 0. So Column A is now at position "1". Column B is at position "2".
4. User resizes Column A to be 200px.
What I get from the above code is:
Column A: Position is 0, Width is 120px, Hidden = false
Column B: Position is 1, Width is 120px, Hidden = false
Column C: Position is 2, Width is 120px, Hidden = false
What I expected/need to get is:Column A: Position is 1, Width is 200px, Hidden = false
Column B: Position is 2, Width is 120px, Hidden = TRUE
Column C: Position is 0, Width is 120px, Hidden = false
What am I missing? Thanks!
Last edited by geoffrey.mcgill; Sep 01, 2010 at 4:50 PM.
Reason: please use [CODE] tags