Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Extjs checkcolumn中获取id?_Javascript_Extjs_Extjs4 - Fatal编程技术网

Javascript 如何在Extjs checkcolumn中获取id?

Javascript 如何在Extjs checkcolumn中获取id?,javascript,extjs,extjs4,Javascript,Extjs,Extjs4,我是Extjs中的tiro 这就是我的模型: Ext.define('CatModel', { extend: 'Ext.data.Model', idProperty: 'id', fields: [{ name: "name", convert: undefined }, { name: "id", convert: undefined }] }); 商店: var store =

我是Extjs中的tiro

这就是我的模型:

Ext.define('CatModel', {
    extend: 'Ext.data.Model',
    idProperty: 'id',
     fields: [{
        name: "name",
        convert: undefined
    }, {
        name: "id",
        convert: undefined
    }]
}); 
商店:

var store = Ext.create('Ext.data.TreeStore', {
    model:'CatModel',
    root: {
        expanded: true
    },
    proxy: {
        type: 'ajax',
        reader: 'json',
        url: 'item_access.jsp?fullpage=true&show_cat=1'
    }
});
和树面板:

var treePanel = Ext.create('Ext.tree.Panel', {
    id: 'tree-panel',
    title: 'Sample Layouts',
    region:'north',
    split: true,
    height: 560,
    minSize: 150,
    rootVisible: false,
    autoScroll: true,
    store: store,
    columns: [
        {
            xtype: 'treecolumn',
            text: 'name',
            flex: 2.5,
            sortable: true,
            dataIndex: 'name'
        },
        {
            text: 'id',//I want to get this id
            flex: 1,
            dataIndex: 'id',
            sortable: true
        }
        , {
            xtype: 'checkcolumn',
            text: 'Done',
            dataIndex: 'done',
            width: 55,
            stopSelection: false,
            menuDisabled: true,
            listeners:{
                checkchange:function(cc,ix,isChecked){
                    //alert(isChecked);
                    //I want to get this row id in here 
                }
            }
        }]
});
checkchange
函数中有三个参数,一个未知,两个是索引,三个是检查状态

那么,如何才能在选中复选框的位置获得相同的行id


我可以通过复选框行索引找到id号吗???

您应该能够使用行索引从树视图中获取记录,然后从中获取id属性:

listeners:{
    checkchange: function(col, idx, isChecked) {
        var view = treePanel.getView(),
            record = view.getRecord(view.getNode(idx));

        console.log(record.get('id'));
    }
}

你能解释一下“行id”的确切含义吗?通常一行基于一条记录(即模型的一个实例),您希望这样吗?表示第一个参数是
已检查属性的节点已更改
。侦听器位于列上,因此您需要引用上的事件,而不是TreePanel@matt我的
treePanel
中有三个列,当我单击“完成”复选框,我想获得相同的行id…@matt所以在我的示例中,不可能获得该id?