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

How to access selected row in a AlloyUI Data Table

本文关键字:数据表 AlloyUI 何访问 访问      更新时间:2023-09-26

我使用的是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");
    }
);

如何获得选定的行数据?如何定义选择事件,点击,双击等?

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