EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: dustinjo on January 26, 2017, 07:12:23 PM



Title: How to change the edit property of the Cell Editing in DataGrid.
Post by: dustinjo on January 26, 2017, 07:12:23 PM
Hi, I am trying to change the edit property of the Cell in the DataGrid for primary key column.
I want to disable the edit if the row exists, but the new row needs to be editable for the key column.
(https://s23.postimg.org/gtw575zfv/table.png)
Please give an advice how to change the cell property in the DataGrid.
Thank you.


Title: Re: How to change the edit property of the Cell Editing in DataGrid.
Post by: jarry on January 26, 2017, 09:04:44 PM
You can modify the 'editor' property of the specified column before editing a row. Please look at the code below:
Code:
$('#dg').datagrid({
  onBeforeEdit: function(index,row){
    var col = $(this).datagrid('getColumnOption', 'field1');
    if (somecondition){
      col.editor = {
        type:'textbox',
        options:{
          //...
        }
      }
    } else {
      col.editor = null;
    }
  }
})


Title: Re: How to change the edit property of the Cell Editing in DataGrid.
Post by: dustinjo on January 27, 2017, 05:58:58 PM
Thank you for your help.
It is working.