Results 1 to 5 of 5

Thread: [EXTJS4.1][MVC] How to reuse a component?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    17
    Vote Rating
    1
      0  

    Question Unanswered: [EXTJS4.1][MVC] How to reuse a component?

    Hi,


    How to reuse a component MVC? Each component should have its own instance of store. Now I create two instances of component (controller, view, store). How to filter data in first component? Only first, without affecting data in second component.


    Regards,
    Marcin

  2. #2
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    I am facing the same problem how can i reuse to same store for different components

  3. #3
    Ext JS Premium Member
    Join Date
    Feb 2011
    Posts
    28
    Answers
    1
    Vote Rating
    4
      0  

    Default

    Quote Originally Posted by purnima_iyer View Post
    I am facing the same problem how can i reuse to same store for different components
    To reuse the same store with multiple components just refer to it by name like this:
    Assuming you have store Sample defined
    Code:
    Ext.define('XX.store.Sample', {...});
    You can refer to it in view(s):
    Code:
    Ext.define('XX.view.PanelX',
      {
        ....
        initComponent: function(){
         this.items = [
           {
               xtype: 'combo',
               itemId: 'comboOne',
               .....
               store: 'Sample'
           },
           {
              xtype: 'grid',
              itemId: 'comboTwo',
              ....
              store: 'Sample'
            }
        ]
       }
      }
    Keep in mind though that both combobox and grid share the same instance of store, so all filtering/sorting/changes to it will be automatically propagated to both.

  4. #4
    Ext JS Premium Member
    Join Date
    Feb 2011
    Posts
    28
    Answers
    1
    Vote Rating
    4
      0  

    Default

    Quote Originally Posted by martio View Post
    Hi,


    How to reuse a component MVC? Each component should have its own instance of store. Now I create two instances of component (controller, view, store). How to filter data in first component? Only first, without affecting data in second component.


    Regards,
    Marcin
    You can use Ext.create to create as many instances as you need, for example:
    Code:
    Ext.define('XX.store.Sample', {....});
    storeA = Ext.create('XX.store.Sample', {storeId: 'A'});
    storeB = Ext.create('XX.store.Sample', {storeId: 'B'});

  5. #5
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Thank you for your reply.I tried to create to instances of the store ,this helps in applying different filtering/sorting/changes to each store

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
  •