EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sky-t on May 21, 2017, 12:09:08 AM



Title: Datagrid disable one or more row(s)
Post by: sky-t on May 21, 2017, 12:09:08 AM
Hi there,

is there a possibility to disable one or more rows in a datagrid?


Thanks for help!


Title: Re: Datagrid disable one or more row(s)
Post by: jarry on May 21, 2017, 01:26:29 AM
You can define the 'rowStyler' function to customize the style for some specified rows.


Title: Re: Datagrid disable one or more row(s)
Post by: sky-t on May 21, 2017, 02:00:19 AM
Hi jarry,

first thank you - i know the rowStyler function - but how can i use it to disable a row?


Thanks again


Title: Re: Datagrid disable one or more row(s)
Post by: jarry on May 21, 2017, 04:03:00 AM
Use the 'rowStyler' to set the row style and use the 'onBeforeSelect' to determine whether a row can be selected. What is the purpose of disabling rows in datagrid?


Title: Re: Datagrid disable one or more row(s)
Post by: sky-t on May 21, 2017, 10:06:45 AM
i want to show a list of all connected users - in this list i want the users to allow to select other users to send them a message for example. The current user is also in this list and i makes no sense if this user sends a message to himself.

Wo this row for each current user should be disabled.


Thank you jarry


Title: Re: Datagrid disable one or more row(s)
Post by: jarry on May 21, 2017, 03:33:23 PM
You only need to prevent the user from selecting some rows. Please return false in the onBeforeSelect event handler regarding some conditions.
Code:
$('#dg').datagrid({
  onBeforeSelect:function(index,row){
    if(...) return false
  }
})


Title: Re: Datagrid disable one or more row(s)
Post by: sky-t on May 21, 2017, 09:22:55 PM
Hi jarry,

thank you for your help - i think this way will work.