Results 1 to 7 of 7

Thread: Kitchen sink Association Example is not working in local server.

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    15

    Default Kitchen sink Association Example is not working in local server.

    Hi All,

    I'am trying to execute the Association example present in Data binding of Kitchensink example in Extjs5. But I'am not able to get the data for my grid.
    Its showing 404 error for the file

    GET http://localhost:1841/Customer?_dc=1...art=0&limit=25 404 (Not Found)

    I have checked in the source code for model/Customer.js , and wondering how the linking to the data is happening, which is there in data/Customer.js.

    Any assistance on this is highly appreciated.

    Thanks in Advance
    Rockz

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Location
    Hyderabad,India
    Posts
    35

    Default

    Hi,

    Here is some hint to your question.
    http://www.sencha.com/forum/showthread.php?292842-Missing-ViewModel-definitions-in-Sencha-Docs-example-for-binding-association

    However, I think I know your issue. Somedays back I faced the same issue.
    Here are some simple steps to follow and u will get rid of the that issue.
    (1)Define a base model as below
    Code:
    Ext.define('App.model.BaseModel', {
        extend: 'Ext.data.Model',
        
        schema: {
            namespace: 'App.model'
        }
    });
    (2)Now define your viewModel inside the view file as below

    Code:
    viewModel: {
            stores: {
                customers: {
                    model: 'Customer',
                    autoLoad: true
                }
            }
        }
    (3)Define your Customer model as below

    Code:
    Ext.define('App.model.Customer', {
        extend: 'App.model.BaseModel',
        fields:['name','contactNo'],
           proxy:{
           type:'ajax'  //whatever suits you ajax,rest,etc..
           url:'your_url_goes_here',
           reader:{
                 type:'json'  // depends on your data structure
               }
          }
    });
    (4)Define your order model as below
    Code:
    Ext.define('App.model.Order', {
        extend: 'App.model.BaseModel',
        fields:[{name:'orderId',
                         reference:{
                                       parent:'Customer'
                                         }
                        }
                      'OrderId'],
           
    });
    If you follow these steps there wont be that issue anymore.



    Thanks

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    15

    Default

    Thanks for your reply.

    I'am able to load my Customer grid now, but on click of record in the grid, the corresponding order is not getting loaded into memory. When am checking for the files data/Orders.js file is not loading in to memory, where the order data are defined.


    Any idea where I'am missing ?


    Thanks in Advance

  4. #4
    Sencha User
    Join Date
    Nov 2012
    Posts
    15

    Default

    Thanks friends I got my code working...

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Location
    Hyderabad,India
    Posts
    35

    Default

    @Rockz,
    Buddy, What you did to make the order grid load.

    R u using the binding syntax for loading the order grid.

    If yes, can u help me here. Becoz, I am not able to load the order grid.
    I think, I am doing wrong with the json data. Please share few of your dummy data.



    Thanks


  6. #6
    Sencha User
    Join Date
    Nov 2012
    Posts
    15

    Default

    @riku351
    For order grid we should use binding config bind: '{customerGrid.selection.orders}'
    There is no binding config required apart from the above , i think there might be some data issue for you. Please check the below links hope it ll resolve your problem.http://dev.sencha.com/ext/5.0.1/exam...ta/Customer.js
    http://dev.sencha.com/ext/5.0.1/exam...model/Order.js
    http://dev.sencha.com/ext/5.0.1/exam.../data/Order.js
    http://dev.sencha.com/ext/5.0.1/exam...ta/Customer.js
    http://dev.sencha.com/ext/5.0.1/exam...p/data/Init.js

    Thanks

  7. #7
    Sencha User
    Join Date
    Nov 2012
    Posts
    15

    Default

    Hi Friends,

    I have tried the example with a json file from where all data is coming and it works fine for me.

    But when a changed the directory structure for my model files its not wokring . For example i moved the file Customer.js to app/model/test/Customer.js and Order.js to app/model/test/Order.js

    In this case Customer data loaded fine for me but on Click of grid record the corresponding Order data is not loading instead am getting error like this:
    [E] Ext.Component.constructor(): Invalid component "id": "2" ext-all-rtl-debug.js?_dc=1414480564190:6155

    For refrence am pasting my sample files
    Customer.js
    Ext.define('myApp.model.test.Customer', {
    extend: 'myApp.model.Base',
    requires: [
    "myApp.model.field.PhoneNumber", "myApp.model.test.Order"
    ],


    fields: [
    'name', {
    name: 'phone',
    type: 'phonenumber'
    }
    ],
    proxy: {
    type: 'ajax',
    url: 'app/data/Customer.json',
    reader: {
    type: 'json',
    rootProperty: 'data',
    successProperty: 'success'
    }
    },


    validators: {
    name: 'presence'
    }
    });

    Order.js:
    Ext.define('myApp.model.test.Order', {
    extend: 'myApp.model.Base',


    fields: [
    { name: 'date', type: 'date', dateFormat: 'Y-m-d' },
    'shipped',
    {
    name: 'customer',
    reference: {
    parent: 'test.Customer'
    }
    }
    ]
    });

    Change in viewModle

    viewModel: {
    stores: {
    customers: {
    model: 'test.Customer',
    autoLoad: true
    }
    }
    },

    Did anybody faced the same problem ? or it a bug in Extjs5 ?

    Any help on this is highly appreciated

    Thanks
    Rockz

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
  •