1

I have a w2ui grid with multiSelect enabled. My goal is to disable selection of certain rows and keep available selection of others.

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/w2ui@2.0.0/w2ui-2.0.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/w2ui@2.0.0/w2ui-2.0.min.js"></script>
<div id='grid' style='height:500px'></grid>

Would be possible to allow record selection only on some records?

Stefano Radaelli
  • 1,088
  • 2
  • 15
  • 35

1 Answers1

0

With method event.preventDefault() onSelect event:

            onSelect(event) {
                if ( disable.selection == true ) event.preventDefault()
            }
Stefano Radaelli
  • 1,088
  • 2
  • 15
  • 35