Results 1 to 5 of 5

Thread: What's the proper way to iterate over columns of a grid ?

  1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    12

    Default What's the proper way to iterate over columns of a grid ?

    Hi!

    I was wondering about the cleanest way to access the columns of an Ext.grid.Panel in Ext4... I am asking here because I didn't find any clear public method or property in the doc. Of course, there is "columns", but that's a config option, not a public property and, in my mind, that's not safe to consider that as part of the API... Maybe I am wrong on this ?

    In Ext3 there was a convoluted but clearly public way of doing this, using ColumnModel methods.

    So, in Ext4, provided you only start with a reference to a grid panel, how do you iterate over its columns using only a safe public API ?

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347

    Default

    You can use <grid>.headerCt.getGridColumns() which returns an array of grid columns.

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    12

    Default

    Thanks for your answer, but headerCt is not documented public either (in fact, if the search in the doc is working properly, it is not documented at all). I could go with:

    Code:
    <grid>.getView().getHeaderCt()
    But here again getHeaderCt() is documented private...

    I guess I should stick with <grid>.columns which, at least, clearly conveys the intention (or, better, override Ext.panel.Table to add and expose getColumns() myself).

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890
    Answers
    41

    Default

    getHeaderCt should be public.

  5. #5
    Sencha User
    Join Date
    Jun 2010
    Posts
    12

    Default

    Probably, but I still don't feel that would be the best answer to my original question. That would not give an obvious way to access the columns, and the Column class represents more than just the header information (visibility, renderer, format, etc.). Furthermore a grid is not required to display a header...

    Anyway, Animal, I appreciate that you're showing interest in the completeness of the documentation -- I was thinking maybe it was me being a bit of an extremist here.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •