Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Viewmodel links config

  1. #11
    Sencha Premium User
    Join Date
    Mar 2015
    Posts
    40
    Vote Rating
    0
      0  

    Default

    Right now I came up with an ajax request where on response the linkTo method is used where data is passing through the model to set a defaults in case no data is loaded:
    Code:
    Ext.Ajax.request({
        url: '/base_url/' + id,
        method: 'GET'
    }).then(function(response) {
        var data = Ext.decode(response.responseText);
        grid.getViewModel().linkTo('custom',{
             reference:'CustomModel',
             create: data
        });
    }).done();
    
    
    Ext.define('CustomModel',{
        extend:'Ext.data.Model',
        fields:[
            { name:'name', defaultValue:'default name'},
            { name:'value', defaultValue:'default value'}
        ]
    });
    The more proper solution will be appreciated.

  2. #12
    Sencha Premium User
    Join Date
    Sep 2011
    Location
    Tamworth, NSW, Australia
    Posts
    1,352
    Answers
    13
    Vote Rating
    424
      0  

    Default

    Quote Originally Posted by valgussev View Post
    I have a corresponding to the topic question, is it possible to set a dynamic url using links as it is done for stores? i.e.
    Code:
    links: {
      foo: {
        type: 'MyApp.model.TestModel',
        proxy: {
          url: '/base_url/{id}'
        }
      }
    }
    I've just be tidying up some horrible old code I did 5 years ago, and found this in my search to refresh my memory about links. I've just done what you're trying to do (and have probably figured out by now!), but I didn't add the {id} to the URL. The viewmodel automatically appends it to the URL of model's associated proxy when it loads:

    Code:
        proxy: {
            type: 'rest',
            url: '../Service/Whatever/',
            reader: {
                type: 'json',
                rootProperty: 'data'
            }
        }
    {id} will be appended after Whatever/ automatically.

    PS, I should say that I'm now using Ext 6.2 so I'm not sure if this is the behaviour in 5 (I guess it probably is).

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •