Results 1 to 4 of 4

Thread: Databinding ViewModel and grid doesn't work

  1. #1
    Sencha User
    Join Date
    Aug 2014
    Posts
    13
    Answers
    1

    Default Databinding ViewModel and grid doesn't work

    I have a user model:
    PHP Code:
    Ext.define('CrudTest.model.User', {  
      
    extend'Ext.data.Model'
      
    idProperty'Id',
        
    fields: [   
         { 
    name'Id'type'int' },   
         { 
    name'Name'type'string' },  
         { 
    name'PhoneNumber'type'int' },  
         { 
    name'Address'type'string' },    
         { 
    name'StateName'type'string' },   
         { 
    name'StateId'type'int'reference'State' },    ],  
       
    proxy: {  
          
    type'rest',     
       
    url:'users',     
       
    writer: {            writeAllFieldstrue        },     
     },
    }); 
    and users store:
    PHP Code:
    Ext.define('CrudTest.store.Users', {  
      
    extend'Ext.data.Store'
      
    model'CrudTest.model.User',  
      
    autoLoadtrue,   
     }); 
    and a UserViewModel Viewmodel:
    PHP Code:
    Ext.define('CrudTest.viewmodel.UserViewModel', {
    extend'Ext.app.ViewModel',    
    alias'viewmodel.uservm',     
    stores:{ users:  new CrudTest.store.Users()},
    }); 
    and a grid to show users:
    PHP Code:
    Ext.define('CrudTest.view.Grid', {  
    extend'Ext.grid.Panel'
    requires: ['CrudTest.store.Users''CrudTest.store.States''CrudTest.model.RegisterUserVM''CrudTest.viewmodel.UserViewModel'], 
    alias'widget.myGrid',   
    viewModel: {        type'uservm',            }, 
    columns: [  
         { 
    text'Name'bind'{users.name}' },    
         { 
    text'PhoneNumber'bind'{users.PhoneNumber}' },   
         { 
    text'Address'bind'{users.Address}'sortablefalse, },
            ],}); 
    grid load well when set store of my grid to users store. but i need viewmodel binding that in this case my grid apeare without any row and no extjs error. am i doing right? tnx.

  2. #2
    Sencha User
    Join Date
    Aug 2014
    Posts
    13
    Answers
    1

    Default

    could you give me a tutorial about viewmodel binding in extjs 5?

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Have you seen this page from the docs?
    http://docs.sencha.com/extjs/5.0/app...a_binding.html

  4. #4
    Sencha User
    Join Date
    Aug 2014
    Posts
    13
    Answers
    1

    Default

    Yes, tnx Gary Schlosberg , finally i found my grid just shows data as simple as some rows so i don't need viewmodel for grid. actually i get confused in viewmodel usage. i solved it.

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
  •