Support for editing only few cells of a row

1 Answer 69 Views
Editor Grid
Janaki Ram
Top achievements
Rank 1
Janaki Ram asked on 06 Jan 2023, 01:19 PM

Hi,

I have a requirement where I have to enable editing of only few cells of a row (Please note that for each row different set of cells can be editable). I found that we have a field called as "inEdit" which if true will mark all the cells of that row as editable. My idea is to implement cellRender function where I can enable editing of a particular cell based on certain conditions. 

Could you please let me know how this can be achieved?

Thanks,

Janaki

Janaki Ram
Top achievements
Rank 1
commented on 10 Jan 2023, 07:16 AM

Hi,

Any update on this please?

Thanks,

Janaki

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 10 Jan 2023, 08:34 AM

Hello Janaki,

Thank you for contacting us.

From what I understand you are using the inline editing. Using the cellRender would be possible, but you will have to implement logic that will render the view cells for the cells that you don't want to be editable for the row (based on your conditions within the dataItem):

In the above example I have added a very basic example on how to prevent the default rendering of the ProductName editor cell and replace it:

  const cellRender = (td, props) => {
    if (props.rowType == 'data' && props.dataItem.inEdit) {
      if (props.field == 'ProductName') {
        return <td {...td.props}>{props.dataItem[props.field]}</td>;
      }
    }
    return td;
  };

You can replace the inner condition with your custom logic for determining which field should not be editable.

Another solution would be to define custom "cell" for the columns and add the rendering logic inside each cell:

As you will notice in the custom myDropDownCell, the only condition for rendering the cell with the editor is dataItem.inEdit, so you can modify it by adding additional logic for rendering the editor.

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Janaki Ram
Top achievements
Rank 1
commented on 10 Jan 2023, 09:22 AM

Hi Konstantin,

Thanks a lot for your support! The example code has been very helpful.

Regards,

Janaki

Tags
Editor Grid
Asked by
Janaki Ram
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or