与服务器端的协会合作;表关系

时间:2015-07-05 15:40:12

标签: extjs associations

我需要做这样的事情,但在服务器端。 http://dev.sencha.com/ext/5.1.0/examples/kitchensink/#binding-associations

我的代码(当我选择一个Customers网格行时):

selectionchange: function(sm, grid, value, selected, eOpts) {

    var storeCustomers = grid.getStore();

    var gridOrders = Ext.ComponentQuery.query('#gridOrdersItemId')[0];
    var storeOrders = gridOrders.getStore();        

    var id_customers = storeCustomers.findRecord('id_customers', value); //It does not work; return null

    console.log(id_customers ); //null
    console.log(value); //undefined

    storeOrders.proxy.extraParams = {
            'id_customers': id_customers
    },

    storeOrders.load();

}

由于某种原因,当我选择网格记录时,我无法获得id_customers的值。结果为空。

知道如何解决这个问题吗?

提前致谢。

编辑:06-07-2015

selectionchange: function(sm, grid, record, value, selected, eOpts) {

    var storeCustomers = grid.getStore();

    var gridOrders = Ext.ComponentQuery.query('#gridOrdersItemId')[0];
    var storeOrders = gridOrders.getStore();        

   var records = grid.getSelectionModel().getLastSelected(record);

    storeOrders.proxy.extraParams = {
            'id_customers': records.get('id_customers')
    },

    storeOrders.load();

}

1 个答案:

答案 0 :(得分:1)

关于这个:

  

出于某种原因,当我选择时,我无法获得id_customers的值   网格记录。结果为空。

这是一个可能的解决方案:

selectionchange: function(grid, records) {
    var storeOrders = Ext.ComponentQuery.query('#gridOrdersItemId')[0]
                                        .getStore();
    storeOrders.proxy.extraParams = {
            'id_customers': records[0].get('id_customers')
    },
    storeOrders.load();
}