Results 1 to 7 of 7

Thread: Remember Open nodes Row Expander Modern View on grid refresh

  1. #1
    Sencha Premium User
    Join Date
    Mar 2017
    Posts
    8

    Default Answered: Remember Open nodes Row Expander Modern View on grid refresh

    Greetings,

    using ext 6.5.3, chrome broswer

    Can someone explain to me how to manually open a grid's rowexpander for a particular row in modern view.

    I know there are ways to keep track of the nodes the users already has open using an array and overriding the rowexpander plugin see below:

    Code:
    Ext.define('MyApp.overrides.RowExpander', {
        override:'Ext.grid.plugin.RowExpander',
        
        constructor: function() {
            this.callParent(arguments);
            this.expandedRows = [];
            this.cellRows = [];
        },
    
        getExpandedRows:function(){
            return this.expandedRows;
        },
        onGridTap: function(e) {
            console.log(e);
            var el = e.getTarget(),
                cell = Ext.Component.from(e),
                row = cell.row;
                console.log(row);
                //console.log(cell);
                if(!Ext.Array.contains(this.expandedRows,cell.getRecord().id)){
                    this.expandedRows.push(cell.getRecord().id);
                }else{
                    var i = Ext.Array.indexOf(this.expandedRows,cell.getRecord().id,0);
                    Ext.Array.remove(this.expandedRows,cell.getRecord().id);
                }
    
                if (row.getGrid() === this.getGrid()) {
                    row.toggleCollapsed();
                }        
        }
    
    
    });
    
    But I'm not sure how to expose the grid plugin to allow for me to manually open them again after fresh. In my maincontroller I have a function that is called on grid refresh that checks for open expanders and tries to reopen them. I did get this to work in 6.2 but it no longer works in 6.5 See below
    Code:
    onStoreChange_lm:function(sender , value , oldValue , eOpts){        
            var grid = Ext.ComponentQuery.query('#mygrid')[0];
            var a = grid.getPlugins('rowexpander')[0].getExpandedRows();
            Ext.Array.each(grid.getViewItems(),function(name,index){
                //console.log(name._record);
                if(a.length && name.hasOwnProperty("_record")){
                    if(Ext.Array.contains(a,name._record.id)){
                        //console.log(index);
                        if(name._record.id == grid.getViewItems()[index]._record.id){
                            var t = grid.getViewItems()[index];
                            t.cells[0].addCls('x-expanded');
                            //console.log(grid.getViewItems()[index].cells);
                            //t.cells[0].recordsExpanded[name._record.id] = true;
                            t.expand();
                        }
                    }else{
                        //console.log('NOT ONE:'+name._record.id+" index = "+index);
                       // console.log(grid.getViewItems()[index].cells);
                        grid.getViewItems()[index].cells[0].removeCls('x-expanded');
                        //debugger;
                        //grid.getViewItems()[index].cells[0].recordsExpanded[name._record.id] = false;
                    }
                }
            });
    
          }
    Please excuse my ignorance.

    Thank you for your time!

    -Calvin J. Buster

  2. UPDATED



    I have overrided the 'Ext.grid.Row' class. Now the grid remembers the expanded rows after reload of the store. It needs server side recordId, with generated ones may work buggy.

  3. #2
    Sencha User
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default


  4. #3
    Sencha Premium User
    Join Date
    Mar 2017
    Posts
    8

    Default Almost There

    Quote Originally Posted by yeghikyan View Post
    Thanks again for the help sir. Really appreciate it!!

    More questions heh..

    1. In my fiddle is there a way to perserve the rows that have been expanded without the flicker you should see?
    2. Am I going about this the right way, for example, should I be using the refresh event on the grid to do this? If yes how, because I still get the flicker when I have tried that.
    3. I believe what I need is, as the grid renders each row it checks and expands as needed. That way it doesn't look like it is closed and then opening.
    4. Any comments on my coding would be much appreciated. Does and dont's..that kind of thing...


    Things to note. Give the fiddle 5 seconds to poll..it will open two rows..then let it will poll again and you will see the flicker (because it's closing and opening)..




    Thank you again!
    -Calvin

  5. #4
    Sencha Premium User
    Join Date
    Mar 2017
    Posts
    8

    Default

    Anyone, have any idea? I'm at a lost..

  6. #5
    Sencha User
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    UPDATED



    I have overrided the 'Ext.grid.Row' class. Now the grid remembers the expanded rows after reload of the store. It needs server side recordId, with generated ones may work buggy.

  7. #6
    Sencha Premium User
    Join Date
    Mar 2017
    Posts
    8

    Default

    Thank you sir. That really helps me understand how far off I was in my thinking.

  8. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    45
    Answers
    1

    Default

    So for modern we can't have nested grid like classic?
    e.g. https://fiddle.sencha.com/#fiddle/252e

Similar Threads

  1. Replies: 1
    Last Post: 25 May 2017, 3:49 PM
  2. Replies: 6
    Last Post: 15 Apr 2016, 2:35 PM
  3. Tree / TreeGrid - remember opened nodes?
    By oobi in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 13 Feb 2011, 3:01 PM
  4. Reload Tree and and remember expanded Nodes
    By sheddy in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 17 Sep 2008, 11:43 PM
  5. row expander remember expansions on store reload?
    By robasi in forum Sencha Ext JS Q&A
    Replies: 1
    Last Post: 7 Dec 2007, 12:57 PM

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
  •