1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    4
    Vote Rating
    4
    nandavanan is on a distinguished road

      1  

    Default Dynamically adding plugins to grid

    Dynamically adding plugins to grid


    Hi,

    I have grid with plugins like this.

    Code:
    var grd = new Ext.grid.GridPanel({
        	frame: true,
        	minHeight: 200,
        	plugins: [groupSummary,gridSummary,group],
        });
    Assume that I have rendered the grid and loaded the store for the same.
    Now "after loading the grid", when I click on a button, or any event for that matter, I want to
    a) remove all the plugins for the grid,
    b) add new plugins and
    c) refresh the gridView, "without reloading the store" for the grid.

    Any ideas how to get this done?

    Any advice is appreciated.

    Thanks,
    nandavanan

  2. #2
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      -1  

    Default


    Please post in the Ext Help section next time. Community Discussion is not the proper place.


    Moving to Ext help.

  3. #3
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      -1  

    Default


    There is no proper way to "destroy" or "remove" plugins in Ext JS 3.x. Lots of plugins don't have proper destroy methods. Even if they do (like the ones I've developed), you would have to manually remove them from the "plugins" array.

  4. #4
    Sencha User
    Join Date
    Sep 2010
    Posts
    4
    Vote Rating
    4
    nandavanan is on a distinguished road

      1  

    Question Thanks. But,...

    Thanks. But,...


    Thank you for getting back to me.

    If I have plugin_array = [array_of_plugins] and I loaded a grid with this plugin. I, then manipulate the plugins array, new_plugin_array = [new_array_of_plugins]. Now, how do I make the grid look at this new array of plugins for its plugins?

    Is there a function or a property like grid.add({plugins: new_plugin_array}) ?

    Thank again.

  5. #5
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      -1  

    Default


    Code:
    var newPlugin = new MyPlugin();
    newPlugin.init(grid);
    grid.plugins.push(newPlugin);

  6. #6
    Sencha User
    Join Date
    Sep 2010
    Posts
    4
    Vote Rating
    4
    nandavanan is on a distinguished road

      1  

    Default Intersting...

    Intersting...


    Okay, this looks good.

    I was able to change the plugins for the grid. But, they do not seem to have any effect on the grid.

    I am using grid.view.refresh() function to apply the new plugins. Am I supposed to use any other function?

    Also, I am using the columnHeaderGroup plugin. My requirement is to change this plugin, remove its previous version from the grid and add the new version to the same. I also add columns and change the way the values are calculated. All the changes are taking effect except the grouping of headers.

    Thank for the help.

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    No need to replace the ColumnHeaderGroup plugin. You only need to change the rows property of the columnmodel.

  8. #8
    Sencha User
    Join Date
    Sep 2010
    Posts
    4
    Vote Rating
    4
    nandavanan is on a distinguished road

      1  

    Thumbs up I got it...kinda

    I got it...kinda


    Hi,

    I got what you meant...to have the columheadergroup for the to-be-added columns ready even before the grid is created. This worked.

    But, I am worried about the layout.

    I have attached the screen-shot ( tgl-effect-scrn.jpg )of the grid column headers before and after the toggle. As you can in the "after toggle" screen-shot, the width of the newly added columns under "G" are larger in width.

    Any ideas how to spread the column widths evenly?

    Thank you once again. Let me know if you need me to open a new thread for this.

  9. #9
    Ext JS Premium Member
    Join Date
    Jan 2010
    Location
    USA
    Posts
    8
    Vote Rating
    1
    pankajsharma is on a distinguished road

      1  

    Default


    image1.jpg

    I am dynamically adding column to grid and after addition Ext.ux.grid.FilterRow is not retained.
    so i used below mentioned code but still no luck.

    var filterRow = new Ext.ux.grid.FilterRow();
    filterRow.init(grid);
    grid.plugins.push(filterRow);
    grid.getView().refresh();

  10. #10
    Sencha User
    Join Date
    Jul 2008
    Posts
    25
    Vote Rating
    1
    MarkMan55 is on a distinguished road

      1  

    Default BUMP...

    BUMP...


    Bumping this thread. I'm running into the exact same issue and have found the same recommendation in other threads and forums -- which does not work, at least with 3.2.1

    Note: the plugin I'm using is RowExpander
    I've tried different variations of:

    Code:
    var myExpander = new Ext.ux.grid.RowExpander({...});
    myExpander.init(grid)
    grid.plugins.push(myExpander);
    grid.getView().refresh();


    Would love to see another suggestion, thanks!
    Last edited by MarkMan55; 3 Apr 2012 at 10:41 PM. Reason: added code that was tried

Similar Threads

  1. Ext.ux.plugins.CustomColumnMenu [Adding custom itens to grid columns headers]
    By BoogieMonster in forum Ext 2.x: User Extensions and Plugins
    Replies: 4
    Last Post: 11 Mar 2010, 7:15 AM
  2. Ext.grid.GridPanel - adding plugins dynamic
    By phedoreanu in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 26 Jun 2009, 1:20 AM
  3. adding plugins to a grid after grid is created
    By Lasagne in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 3 Jun 2008, 11:44 PM
  4. [2.1] Ext.ux.plugins.InvalidCell : Adding an error message to a cell in a grid
    By arnold in forum Ext 2.x: User Extensions and Plugins
    Replies: 0
    Last Post: 18 May 2008, 3:56 AM

Thread Participants: 6

Tags for this Thread