Results 1 to 2 of 2

Thread: viewController does not load viewModel's store

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2015
    Posts
    1

    Default Answered: viewController does not load viewModel's store

    Hello. This is my first post.

    I'm stuck with view controller.
    I made a renderer function in view controller, and call a store from view model using getStore() function.
    But I cann't load this store in view controller.
    Just a few times I can see rendered data only when store.isLoaded() function returns true.
    How can I solve this problem?

    grid columns
    Code:
    Ext.define('Admin.view.task.Task', {
     extend: 'Ext.panel.Panel',
     controller: 'task',
     viewModel: 'task',
     items:[{
       xtype: 'grid'
       bind: '{task_list}' // -- it works fine
       columns:[
        { text: 'am/pm'
          renderer: 'render_ampm'
        }
    ...
    view model
    Code:
    Ext.define('Admin.view.task.TaskModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.task',
    stores: {
            task_list: {
                type: 'task'
    },
    code_ampm: {
                type: 'code_master',
    proxy: {
                    url: '/api/code_master/ampm'
    },autoLoad: true
    },...
    view controller
    Code:
    ...
    
    init: function(view) {
        var vModel = view.getViewModel();
    this.ampm_store = vModel.getStore('code_ampm');
    },
    render_ampm: function(value){
    
        console.log('isLoading? : ' + this.ampm_store.isLoading()); // almost returns true
        console.log('isLoaded? : ' + this.ampm_store.isLoaded()); // almost returns false
        var ampm = value ? this.ampm_store.findRecord('codeId', value) : null;
        return ampm ? ampm.get('codeName') : 'code error';
    }
    ...
    findRecord() returns null because store has not loaded yet.
    so I tried store.on('load', ...
    but it doesn't work.
    do you know what I should try?

  2. Hi, here is a thread with solution.

  3. #2
    Sencha Premium Member yorl1n's Avatar
    Join Date
    Mar 2015
    Location
    Germany
    Posts
    294
    Answers
    30

    Default

    Hi, here is a thread with solution.

Similar Threads

  1. Component ViewModel / ViewController references
    By mark bjerke in forum Sencha Architect User Extensions/Templates
    Replies: 0
    Last Post: 18 May 2015, 2:15 PM
  2. Replies: 5
    Last Post: 4 Feb 2015, 11:39 AM
  3. Replies: 2
    Last Post: 1 Feb 2015, 4:04 PM
  4. How to delete ViewModel and ViewController?
    By marc.fearby in forum Sencha Architect 3.x: Q&A
    Replies: 2
    Last Post: 1 Feb 2015, 1:45 PM
  5. Replies: 4
    Last Post: 23 Oct 2014, 8:51 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
  •