Results 1 to 6 of 6

Thread: Ext.grid.Panel: How to restore initial column config?

  1. #1
    Sencha User
    Join Date
    May 2016
    Posts
    10

    Default Ext.grid.Panel: How to restore initial column config?

    Dear Forum,

    just a short question: I have grid (Ext.grid.Panel) bound to an arraystore with many columns, each column having their individual initial config (i.e.: width, editor, text, summarytype, etc.).

    Many of these settings are later changed programmatically.

    What's the easiest way to restore the initial column configuration programmatically on click of a button?

    I tried saving the variable Ext.grid.Panel.initialConfig to a global variable after the grid is first loaded but I found no way to later reapply this config again.

    Thanks for any tips,
    XBTC!

  2. #2
    Sencha Premium User varsos's Avatar
    Join Date
    Feb 2008
    Location
    Long Island, NY
    Posts
    367
    Answers
    6

    Default

    You can try to reconfigure with the original array of columns: grid.reconfigure(grid.columns);
    varsos

  3. #3
    Sencha User
    Join Date
    May 2016
    Posts
    10

    Default

    Thanks for your answer varsos.

    The problem with your idea is that grid.columns already contains the changes made programmatically (for example setting different editors, changig column titles, etc.).

    I would need to pass the initial declarative column config that was used when first creating the grid as a parameter to grid.reconfigure(). Is there a way to get the initial config?

  4. #4
    Sencha Premium Member
    Join Date
    Dec 2012
    Location
    Seattle, WA
    Posts
    423
    Answers
    34

    Default

    Have you tried getInitialConfig()? https://docs.sencha.com/extjs/6.2.0/...tInitialConfig

  5. #5
    Sencha User
    Join Date
    May 2016
    Posts
    10

    Default

    Thanks for your answer. Yes I tried that. If I do getInitialConfig('columns') the return value is undefined and if i just do getInitialConfig() I get an object which does not have a member columns. It seems that the documentation is correct in stating:

    Returns the initial configuration passed to the constructor when instantiating this class.
    As the columns of my grid are defined in a declarative way and not passed to the constructor they are not available it seems?

    I found a way to get the original declarative column config though: grid.self.prototype.columns

    However after doing a grid.reconfigure (store, grid.self.prototype.columns) the grid looks as expected but does not work properly anymore (grid.columns is undefined afterwards for example and other weirdness happening - maybe a bug in ExtJS?).

    So for now i decided on just completely removing/destroying and readding the grid.

  6. #6
    Sencha Premium Member Trevor4001's Avatar
    Join Date
    Sep 2013
    Posts
    113
    Answers
    2

    Default

    It doesn't seem that the initial columns configuration is stored on the grid, view table, nor column manager. I worked around this by storing it on the grid in the constructor.
    Code:
    Ext.define('MyApp.grid.Panel', {
       extend: 'Ext.grid.Panel',
    
       // An array of initial column configurations
       initialColumns: null,
    
       constructor: function(config) {
          this.initialColumns = (Ext.isObject(config) ? config.items : config);
       },
    
       reconfigure: function(store, columns) {
           if (columns === true) {
             columns = this.initialColumns
          }
    
          this.callParent(arguments);
       }
    });
    Trevor Karjanis

Similar Threads

  1. Replies: 12
    Last Post: 5 Dec 2014, 6:34 AM
  2. Restore state of grid panel
    By mwilliamsShields in forum Ext: Q&A
    Replies: 5
    Last Post: 14 Jul 2014, 6:42 AM
  3. Replies: 2
    Last Post: 18 Mar 2011, 12:04 AM
  4. [2.??] Ext.Panel AutoScroll not working on initial HTML config object
    By foxwhisper in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 5 Dec 2008, 8:26 AM

Posting Permissions

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