简体   繁体   English

如何在 Extjs checkcolumn 中获取 id?

[英]How can I get the id in Extjs checkcolumn?

Im tiro in Extjs.我是 Extjs 中的 tiro。

That is my model:那是我的模型:

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

store:商店:

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'
    }
});

and treePanel:和树面板:

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 
                }
            }
        }]
});

In checkchange function there are three parameter one unknown,two is index, and three is check status ...checkchange函数中有三个参数,一个是未知的,两个是索引,三个是检查状态......

So how can I get the the same row id where I check the checkbox??那么如何在我选中复选框的地方获得相同的行 ID?

Can I find that id number by checkbox row index??我可以通过复选框行索引找到该 ID 号吗?

You should be able to get the record from the TreeView with the row index, and then get the id property from it:您应该能够使用行索引从 TreeView 获取记录,然后从中获取 id 属性:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM