2011-09-14 47 views
0

我如何獲取使用屬於關聯的記錄?屬於Sencha的關聯

var Category = Ext.regModel('Category', { 
fields: [ 
    {name: 'id', type: 'int'}, 
    {name: 'name', type: 'string'} 
] 
}); 

var Product = Ext.regModel('Product', { 
    fields: [ 
     {name: 'id',   type: 'int'}, 
     {name: 'category_id', type: 'int'}, 
     {name: 'name',  type: 'string'} 
    ], 

associations: [ 
    {type: 'belongsTo', model: 'Category'} 
] 

});

回答

0

阿莫爾,

我只講ExtJS的4,因此,如果你能與這ExtJS的3再大,但你會通過商店檢索多個記錄:

好像你能起點不要

var records = Ext.StoreManager.lookupStore("productStore").load({ 
     belongTo: 'books', 
     callback: function(records) { 
      Ext.each(records,function(record) { 
       console.log(JSON.stringify(record.raw)) 
      }); 
     } 
}); 

根據對productStore的代理設置,這將追加belongsTo關係的查詢字符串,所以如果讀者代理具有網址:/產品及額外參數通過belongsTo被送到這會打擊服務器/產品belongsTo關係? =書籍

+0

從上面的例子我真的想要檢索每個產品的類別名稱。爲此,我使用sfdc Api使用equi連接進行數據庫調用。但一些查詢失敗。 – Amol