Results 1 to 2 of 2

Thread: Adding an attribute to gridcolumn (extjs 4.2.x)

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    37
    Answers
    1

    Default Adding an attribute to gridcolumn (extjs 4.2.x)

    I have a grid, and I need to add an attribute to the TD of the grid cell (not the header, the cell in the grid itself). It will probably be the same text at the column header, so I'd like to just define it in the gridcolumn xtype when I'm creating my columns. In doing some research I've found a tdAttrs config which I think would help, but I'm not entirely sure how to implement it. Can anyone offer some pointers? If that's not the right direction to be looking, please let me know as well.

    Also, I need this to be added to ALL the gridcolumns in my application, so would I need to add an override for ext.grid.column.Column or put it somewhere else?

  2. #2
    Sencha User
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Quote Originally Posted by jlawton View Post
    I have a grid, and I need to add an attribute to the TD of the grid cell (not the header, the cell in the grid itself). It will probably be the same text at the column header, so I'd like to just define it in the gridcolumn xtype when I'm creating my columns. In doing some research I've found a tdAttrs config which I think would help, but I'm not entirely sure how to implement it. Can anyone offer some pointers? If that's not the right direction to be looking, please let me know as well.

    Also, I need this to be added to ALL the gridcolumns in my application, so would I need to add an override for ext.grid.column.Column or put it somewhere else?
    One way you can do this is via the column renderer (the docs show an example of this very thing, look under "metaData"). The implication of this approach is that you'd have to apply this to every column in order to apply it to every cell, but it is "safe" in that it belongs directly to the API and is meant to be used for exactly these purposes.

    Alternatively, you could be a bit more heavy-handed and create an override of Ext.view.Table in which you customize the renderCell method. If you choose this path, please be aware that it is exactly what it sounds like: an override. So if you upgrade in the future, you'll need to reconcile any changes that have been made in the core with the override that you create.

    Hope that helps!

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
  •