如何访问AlloyUI数据表中的选定行

时间:2016-09-05 19:31:08

标签: javascript alloy-ui yui-datatable

我正在使用AlloyUI 3.0。 我使用了上面的代码:

YUI().use(
    'aui-datatable',
    function(Y) {
        var columns = [
            {label: 'ID', key: 'id'},
            {label: 'Project Name', key: 'name'},
            {label: 'Created At', key: 'created_at'}
        ],
        data = [];

        var myDataTable = new Y.DataTable({
            plugins: [
                {
                    cfg: {
                    selectRow: true
                },
                fn: Y.Plugin.DataTableSelection
                },
                {
                cfg: {
                    highlightRange: false,
                    type: 'rows'
                },
                fn: Y.Plugin.DataTableHighlight
                }
            ],
            columns: columns,
            data: data
        })
        .render("#myDataTable");
    }
);

如何获取所选行数据? 如何定义选择事件,单击,双击等?

1 个答案:

答案 0 :(得分:0)

找到解决方案:     var rowUID = DataTable.get('selection')。rows [0] .guid();     DataTable.getRecord(UID).toJSON();