1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    adms is on a distinguished road

      0  

    Question Answered: setting columnWidth and column header dynamically

    Answered: setting columnWidth and column header dynamically


    hi every body,
    in extjs3 we used the following functions to set proprieties:
    Code:
    var colMod = grid.getColumnModel();
    colMod.setColumnHeader(1, 'new header');
    colMod.setColumnWidth(1, 144);
    but how to do it in extjs4 ?????????
    thanks

  2. What version do you use? In 4.0.7. it works just fine.

  3. #2
    Ext JS Premium Member twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    223
    Answers
    15
    Vote Rating
    3
    twaindev is on a distinguished road

      0  

    Default


    Here's one way:

    Code:
        var col = grid.headerCt.getHeaderAtIndex(1);
        col.setText('new header');
        col.setWidth(144);

  4. #3
    Sencha User
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    adms is on a distinguished road

      0  

    Default


    thanks for reply,
    the following code is working fine
    Code:
    var col = grid.headerCt.getHeaderAtIndex(2);
    col.setText('new header');
    but the statement:
    Code:
    col.setWidth(144);
    sets the new width of the column only if the new width is grater than the old width,
    but if the new width is smaller than the old width , no change in column width why??

  5. #4
    Ext JS Premium Member twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    223
    Answers
    15
    Vote Rating
    3
    twaindev is on a distinguished road

      0  

    Default


    Does the column have a flex config?

    If it does you'll have to set it to 0 (zero) otherwise the width of the column can only be greater than the calculated width.

    Code:
        var col = grid.headerCt.getHeaderAtIndex(1);
        col.setText('new header');
        col.flex = 0;
        col.setWidth(50);

  6. #5
    Sencha User
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    adms is on a distinguished road

      0  

    Default


    sorry twaindev, I still have the same problem,
    my column configuration is:
    Code:
    {
    header : 'Name',
    width:120,
    dataIndex : 'name',
    }
    Code:
    var col = grid.headerCt.getHeaderAtIndex(1);
    col.setText('new header'); //works fine
    col.flex = 0;
    col.setWidth(50); // no result , can't be less than the old width(120)

  7. #6
    Ext JS Premium Member twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    223
    Answers
    15
    Vote Rating
    3
    twaindev is on a distinguished road

      0  

    Default


    What version do you use? In 4.0.7. it works just fine.

  8. #7
    Sencha User
    Join Date
    May 2009
    Posts
    41
    Vote Rating
    0
    adms is on a distinguished road

      0  

    Default


    i'm using extjs4.0.7 now ,and evey thing works fine.
    thank you very much twaindev.
    but i want to ask you , if you have any idea about version 4.1, when to release it?
    is it contain a pivot grid like version 3.2.1?
    is it contain an rtl ?

  9. #8
    Ext JS Premium Member twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    223
    Answers
    15
    Vote Rating
    3
    twaindev is on a distinguished road

      0  

    Default


    I don't know about the release date.

    You can read about the preview here:

    http://www.sencha.com/blog/ext-js-4-...loper-preview/

    Please select the answer that helped you most to close this topic.

Thread Participants: 1