Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Feb 2015
    Posts
    55
    Vote Rating
    1
    agarapati is on a distinguished road

      0  

    Default grid.columns is returning empty array if columns are added to grid using reconfigure

    STAND-ALONE TESTCASE
    https://fiddle.sencha.com/#fiddle/mq2

    ADDITIONAL INFO

    Code:

    Ext version tested:
    • Ext 4.2.2 rev 1144
    Browser versions tested against:
    • ____
    • IE11
    • FF39 (firebug 2.0.x installed)
    • Chrome 44
    Description:
    • Grid columns property is not getting updated if columns are added from controller using reconfigure.
    • As shown in the Fiddle example, our columns will be generated from a ajax call, we are using grid.reconfigure to set store and columns for a grid.
    • We should able to hide/delete the column so we added a delete button in column header.
    • Using handler we tried to get instance of button we tried to use grid.columns[button.colIndex].hide().
    • We observed grid.columns is not getting updated it is giving empty array.
    Steps to reproduce the problem:
    • Open above fiddle url
    • In app/Controlelrs/Grids.js we can see onLaunch method we are defining grid columns and store.
    • We used handler to call hideColumn method in button definition where we tried to use grid.columns
    • Even after grid is reconfigured and columns and data is displayed in browser, grid columns array is not getting updated.
    The result that was expected:
    • grid.columns property should be updated once columns of the grid are added or removed using reconfigure method
    The result that occurs instead:
    • grid.columns property is not getting updated if columns are added to grid from controller using reconfigure


  2. #2
    Sencha - Support Team tristan.lee's Avatar
    Join Date
    Mar 2015
    Posts
    749
    Vote Rating
    39
    tristan.lee has a spectacular aura about tristan.lee has a spectacular aura about tristan.lee has a spectacular aura about

      0  

    Default

    columns is a config property that's unrelated to the columns generated when using reconfigure(). In 4, you can make reference to the private class ColumnManager to get the columns:

    Code:
        hideColumn: function(button, Event) {
            var grid = Ext.getCmp('investmentsGrid'),
                cm = grid.getColumnManager(),
                cols = cm.getColumns();
            
            if (cols.length > 0) {
                cols[button.colIndex].hide();
            }
        }
    Tristan Lee
    Sencha Inc - Support Engineer


    Having an issue? Help us help you - be detailed; provide some code; demonstrate with a fiddle (fiddle.sencha.com)

    Embed your fiddle in your post: [­FIDDLE] id [­/FIDDLE]

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2015
    Posts
    55
    Vote Rating
    1
    agarapati is on a distinguished road

      0  

    Default

    Thanks lee for clarification and helping me out.

Similar Threads

  1. Keep certain grid columns after reconfigure
    By Peter Tierney in forum Ext 5: Q&A
    Replies: 2
    Last Post: 13 Jul 2015, 7:33 AM
  2. Replies: 3
    Last Post: 27 Aug 2014, 12:43 AM
  3. Replies: 3
    Last Post: 4 Dec 2013, 12:14 PM
  4. Replies: 5
    Last Post: 24 Sep 2013, 5:55 PM

Thread Participants: 1