Results 1 to 3 of 3

Thread: ViewModel- autoLoad a store with a parameter

  1. #1
    Sencha User
    Join Date
    Jan 2017
    Posts
    10

    Default ViewModel- autoLoad a store with a parameter

    I'm pretty new to extjs and have a question about autoLoad. I have a ViewModel that autoloads a store. However, that store's read operation takes a single id parameter. I'm not sure how to pass that in. I tried two different things with the store, which I'll post below. The first attempt passed the param in and loads the data, but then the create and destroy methods fail (I'm assuming because they're now expecting sessionId and it's not being passed). The second attempt doesn't load the data. Any suggestions?

    ViewModel:
    Code:
    Ext.define('NOVA.Rsvp.Web.grid.DelegateViewModel', {
        extend: 'Ext.app.ViewModel',
        alias: 'viewmodel.delegate',
    
        stores: {
            delegateStore: {
                type: 'delegateList',
                autoLoad: true,
            }
        }
    });
    Store Attempt 1:
    Code:
    Ext.define('Rsvp.Web.store.DelegateList', {
        extend: 'Ext.data.Store',
        storeId: 'delegates',
        requires: [
                'Rsvp.Web.model.Delegate'
        ],
        model: 'Rsvp.Web.model.Delegate',
        alias: 'store.delegateList',
        proxy: {
            type: 'direct',
            directFn: 'Direct.SessionOrganizer.GetDelegatesBySession',
            paramOrder: ['sessionId'],
            api: {
                create: 'Direct.SessionOrganizer.InsertDelegate',
                destroy: 'Direct.SessionOrganizer.RemoveDelegate'
            }
        }
    });
    Store Attempt 2:
    Code:
    Ext.define('Rsvp.Web.store.DelegateList', {
        extend: 'Ext.data.Store',
        storeId: 'delegates',
        requires: [
                'Rsvp.Web.model.Delegate'
        ],
        model: 'NOVA.Rsvp.Web.model.Delegate',
        alias: 'store.delegateList',
        proxy: {
            api: {
                read: 'Direct.SessionOrganizer.GetDelegatesBySession',
                create: 'Direct.SessionOrganizer.InsertDelegate',
                destroy: 'Direct.SessionOrganizer.RemoveDelegate'
            },
            writer: {
                writeAllFields: true,
                encode: false
            }
        }
    });

  2. #2
    Sencha - Forum Administrator
    Join Date
    Sep 2017
    Posts
    1,006

    Default

    Hi there! Let me see if I can get an answer to your question. Hang tight please!

  3. #3
    Sencha - Support Team
    Join Date
    Sep 2017
    Posts
    67

    Default

    Hi gsmith140,

    Please try with the extraParams object and put the object in the proxy object.

    You can try in the below format :

    proxy : {
    extraParams : {
    'name' : 'value'
    }

    }


    Regards,
    Joe

    Sencha Support

Similar Threads

  1. Pass a parameter to a store's read method while using autoLoad
    By gsmith140 in forum Community Discussion
    Replies: 1
    Last Post: 5 Sep 2018, 1:32 AM
  2. ViewModel - chain viewmodel store to global store.
    By badgerb1 in forum Ext JS 6.x Q&A
    Replies: 3
    Last Post: 15 Sep 2016, 5:57 AM
  3. Passing parameter from View to Viewmodel
    By bkkomal in forum Ext JS 6.x Q&A
    Replies: 3
    Last Post: 20 Jul 2016, 8:42 AM
  4. Replies: 1
    Last Post: 21 Apr 2016, 7:05 AM
  5. ViewModel: Bind store autoLoad property
    By landoni in forum Ext 5: Q&A
    Replies: 1
    Last Post: 14 May 2015, 9:37 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
  •