w2ui 网格:禁用单行选择

问题描述 投票:0回答:1

我有一个启用了多重选择的 w2ui 网格。 我的目标是禁用某些行的选择并保留其他行的可用选择。

let grid = new w2grid({
    name: 'grid',
    box: '#grid',
    multiSelect: true,
    show: {
        selectColumn: true
    },
    columns: [
        { field: 'recid', text: 'recid',  size: '10px', sortable: true, attr: 'align="center"' },
        { field: 'field', text: 'field', size: '500px', sortable: true },
    ],
    records: [
        { recid: 1, field: 'You cannot select this' },
        { recid: 2, field: 'neither this' },
        { recid: 3, field: 'but you can select this' },
        { recid: 4, field: 'or this' },
        { recid: 5, field: 'and what do you think about this?' },
        { recid: 6, field: 'Ok no, not this one' },
        { recid: 7, field: 'as even this must be disabled' },
    ]
})
<link href="https://cdn.jsdelivr.net/npm/[email protected]/w2ui-2.0.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/w2ui-2.0.min.js"></script>
<div id='grid' style='height:500px'></grid>

是否可以只允许对某些记录进行记录选择?

javascript grid selection w2ui
1个回答
0
投票

使用方法 event.preventDefault() onSelect 事件:

            onSelect(event) {
                if ( disable.selection == true ) event.preventDefault()
            }
© www.soinside.com 2019 - 2024. All rights reserved.