How can I determine a gridpanel column's width and position and whether it is hidden.

  1. #1

    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:

    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
  2. #2
    If you are calling a DirectEvent when the Column is moved, you would need to pass any values required on the server-side as Parameters. The Column Width and/or Position are not passed by default.

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 1
    Last Post: Jun 11, 2012, 11:59 AM
  2. Replies: 1
    Last Post: Nov 04, 2011, 8:51 AM
  3. Replies: 2
    Last Post: May 02, 2011, 9:08 PM
  4. Replies: 6
    Last Post: Jun 11, 2010, 12:47 PM
  5. Replies: 4
    Last Post: Aug 04, 2009, 11:37 AM

Tags for this Thread

Posting Permissions