EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jega on February 28, 2022, 08:36:27 AM



Title: [SOLVED]Prevent user from selecting a row in datagrid
Post by: jega on February 28, 2022, 08:36:27 AM
Hi.

After loaddata i select a row with $('#dgDelListFrom').datagrid('selectRow',data.numberInList). This row must be selected to show user which row is the only that can be edited.

In beforeSelectRow i can use return false to prevent user select, but it also prevent my own selectRow.

Any solution for this.

Jesper


Title: Re: Prevent user from selecting a row in datagrid
Post by: jarry on March 01, 2022, 01:08:41 AM
Define a variate to indicate if to select a row.
Code:
$('#dg').datagrid({
  rowSelectable: true,
  onBeforeSelect: function(){
    var opts = $(this).datagrid('options');
    return opts.rowSelectable;
  }
})
After selecting a row, turn off this variate.
Code:
$('#dg').datagrid('selectRow',1)
$('#dg').datagrid('options').rowSelectable = false;


Title: Re: Prevent user from selecting a row in datagrid
Post by: jega on March 01, 2022, 02:00:48 PM
Hi Jarry

Thanks. Works as expected.

But, can't see rowSelectable in the documentation

Jesper