Results 1 to 6 of 6

Thread: update model with json

  1. #1
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    9
    Answers
    1

    Default Answered: update model with json

    i have a model like:
    Code:
    Ext.define('ResultDetail', {
        extend : 'Ext.data.Model',
        fields : [ {
            name : 'id',
            type : 'int'
        }, {
            name : 'email',
            type : 'string'
        } ],
        hasMany : [ {
            model : 'Testresults',
            name : 'testresultsbeans'
        } ],
        proxy : {
            type : 'rest',
            url : myurl
        },
        reader : {
            type : 'rest',
            root : 'resultDetailBean'
        }
    });
    I can receive the Json-Data from sercer-side and i want to get the record value with:
    Code:
    var ResultDetail = Ext.ModelManager.getModel('ResultDetail');
                ResultDetail.load(id,{
                    success: function(resultDetail,operation) {
                                   var email = resultDetail.get("email");
                                   ......
                                    }
                });
    But this dosent work. Can someone tell me, how to automatic update the model record and get the record value?

    Thanks

  2. There is no 'rest' reader, try setting 'json' instead:

    Code:
    Ext.define('ResultDetail', {
        extend : 'Ext.data.Model',
        fields : [ {
            name : 'id',
            type : 'int'
        }, {
            name : 'email',
            type : 'string'
        } ],
        hasMany : [ {
            model : 'Testresults',
            name : 'testresultsbeans'
        } ],
        proxy : {
            type : 'rest',
            url : myurl,
            reader : {
                type : 'json',
                root : 'resultDetailBean'
            }
        }
    });

  3. #2
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,153
    Answers
    33

    Default

    There is no 'rest' reader, try setting 'json' instead:

    Code:
    Ext.define('ResultDetail', {
        extend : 'Ext.data.Model',
        fields : [ {
            name : 'id',
            type : 'int'
        }, {
            name : 'email',
            type : 'string'
        } ],
        hasMany : [ {
            model : 'Testresults',
            name : 'testresultsbeans'
        } ],
        proxy : {
            type : 'rest',
            url : myurl,
            reader : {
                type : 'json',
                root : 'resultDetailBean'
            }
        }
    });

  4. #3
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    9
    Answers
    1

    Default

    thank you for the advice. I 've changed the reader type.

    But it still dosent work.

  5. #4
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    9
    Answers
    1

    Default

    any new idea ?

  6. #5

  7. #6
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    9
    Answers
    1

    Default

    i found the problem. Just add " format : 'json' "
    Thank you for your help.

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
  •