Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another possibility is to create a subclass of GridPanel. The constructor of this subclass can examine its given config for a PagingToolbar config. If one is present, instantiate the store (if needed) and give a reference to it to the PagingToolbar config.</p> <pre><code>var MyGridPanel = Ext.extend(Ext.grid.GridPanel, { constructor: function( cfg ) { if ( cfg &amp;&amp; cfg.store &amp;&amp; cfg.bbar &amp;&amp; cfg.bbar.xtype == 'paging' &amp;&amp; ! (cfg.bbar instanceof Ext.PagingToolbar &amp;&amp; ! this.bbar.store ) { if ( cfg.store.xtype &amp;&amp; ! (cfg.store instanceof Ext.data.Store) ) { cfg.store = Ext.ComponentMgr.create(cfg.store); } cfg.bbar.store = cfg.store; } MyGridPanel.superclass.constructor.call(this, cfg); } }); </code></pre> <p>Example usage:</p> <pre><code>(new Ext.Window({ width: 400, height: 200, layout: 'fit', items: new MyGridPanel({ store: { xtype: 'arraystore', fields: ['name', 'value'], data: [ ['name 1', 'value 1'], ['name 2', 'value 2'] ] }, columns: [ { dataIndex: 'name', header: 'Name' }, { dataIndex: 'value', header: 'Value' } ], bbar: { xtype: 'paging', pageSize: 25 } }) })).show(); </code></pre> <p>Another option is to use createInterceptor to apply the above behavior to the GridPanel directly:</p> <pre><code>Ext.grid.GridPanel.prototype.initComponent = Ext.grid.GridPanel.prototype.initComponent.createInterceptor(function() { if ( this.store &amp;&amp; this.bbar &amp;&amp; this.bbar.xtype == 'paging' &amp;&amp; ! (this.bbar instanceof Ext.PagingToolbar) &amp;&amp; ! this.bbar.store ) { if ( this.store.xtype &amp;&amp; ! (this.store instanceof Ext.data.Store) ) { this.store = Ext.ComponentMgr.create(this.store); } this.bbar.store = this.store; } }); </code></pre> <p>This would allow you to continue using xtype: 'grid'.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload