Results 1 to 6 of 6

Thread: State manager: Reset layout

  1. #1
    Sencha User
    Join Date
    Oct 2015
    Posts
    37
    Answers
    1

    Default State manager: Reset layout

    Hey,

    I'm not really able to reset layout on ExtJs 6 through my controller. I tried this:
    Code:
        onResetLayout: function (button, e, options) {
    
            var grid = this.lookupReference('itemsGrid');
            Ext.state.Manager.clear(grid.stateId);
    
            //var a = grid.down('headercontainer').getGridColumns();
            //var a = grid.down('headercontainer').getVisibleGridColumns();
           
            var a = grid.columnManager.getColumns();
            var c = Ext.Array.slice(a);
         
    
            grid.reconfigure(c);  //[{ text: 'Name', dataIndex: 'name', flex: 1 }]
    
        },
    Mostly I get nothing or this error:
    Code:
    [E] Ext.container.Container.add(): Cannot add destroyed item 'gridcolumn-1043' to Container 'headercontainer-1041'
    It only works when I use hardcoded part:
    Code:
    grid.reconfigure(null, [{ text: 'Name', dataIndex: 'name', flex: 1 }]);
    What I need basically is that I could reset grid to default layout.


    Any ideas?

  2. #2
    Sencha User
    Join Date
    Oct 2015
    Posts
    37
    Answers
    1

    Default

    bump

  3. #3
    Sencha - Sustaining Engineer tristan.lee's Avatar
    Join Date
    Mar 2015
    Location
    Central Ohio
    Posts
    1,579
    Answers
    165

    Default

    In your first example, you're only passing 1 argument to reconfigure. In the second, the first argument is now null. I'm not sure exactly without seeing an example though.
    Tristan Lee
    Sencha Inc - Sustaining 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]

  4. #4
    Sencha User
    Join Date
    Sep 2015
    Posts
    36

    Default

    Any progress on this issue?

  5. #5
    Sencha Premium User
    Join Date
    Jun 2011
    Posts
    16
    Answers
    2

    Post

    Having just run into this problem myself the error is because the reconfigure is expecting an array of Javascript objects - the same as you pass to the initial grid configuration. The getColumns method returns an array of ExtJS objects - references to the actual constructed columns.

    Presumably the first thing the reconfigure does is delete all the existing columns which invalidates the ExtJS column object you're trying to push back - hence the error message. There is a method to get the initial config of the column which you may find helpful.

    Code:
     
    var columns = grid.getColumns(), l, i, col, newCols;
    l = columns.length;for (i = 0; i < l; i++) {
        col = columns[i];
        newCols.push(col.getInitialConfig());
    }
    grid.reconfigure(newCols);
    However I ran into an error message re: sorter is null when doing this so there may be extra work required in copying only the minimal config from the "initial config objects". I only need to set up dynamic columns when the grid loads the first time so just set up all the columns as if I was adding them as standard Javascript objects in standard config, just using reconfigure to update the grid.

  6. #6
    Sencha - Sustaining Engineer tristan.lee's Avatar
    Join Date
    Mar 2015
    Location
    Central Ohio
    Posts
    1,579
    Answers
    165

    Default

    If you have an example producing the error I can take a look.
    Tristan Lee
    Sencha Inc - Sustaining 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]

Similar Threads

  1. Replies: 5
    Last Post: 26 Jun 2015, 10:07 AM
  2. How to reset the grid state to the state when it got first rendered.
    By samir_ware in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 31 Aug 2012, 8:52 AM
  3. Replies: 1
    Last Post: 3 Sep 2011, 1:58 AM
  4. Replies: 7
    Last Post: 30 Apr 2011, 12:25 PM
  5. Replies: 3
    Last Post: 4 Jun 2008, 4:25 AM

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
  •