This is a migrated thread and some comments may be shown as answers.

How to edit a column in a grid instead of a row or cell.

2 Answers 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rebekah
Top achievements
Rank 1
Rebekah asked on 04 Oct 2018, 05:02 PM

I have two cases where I need to be able to put a column in "edit mode". Is there any way to do this? 

1. I have a grid with an edit button in the column header template. Clicking the button puts the whole column in edit mode. Save and cancel buttons appear when the column is in edit mode.

So far I have been able to do this by putting conditional fields in the column cell template. I can show them based on the column index when the edit button for that column is clicked, but I can't assign them to a form group if they aren't in the "kendoGridEditTemplate".

2. I have a grid where the user needs to edit on cell click, but this should put the whole column in edit mode and not just the cell that was clicked. I am able to get the column index from the click event and hoped to use this to put the rest of the cells in edit mode, but I get stuck when trying to use the editCell method. I tried doing a foreach on my data and passing the index of each object into editCell in place of rowIndex, but all I got was a single field displaying in the last row for some reason.

Any ideas/assistance would be much appreciated. 

2 Answers, 1 is accepted

Sort by
0
Accepted
Svet
Telerik team
answered on 08 Oct 2018, 12:21 PM
Hi Rebekah,

Indeed, we can use the kendoGridCellTemplate, within which we can define a view for when the column is not in edit mode and another view, that holds an input element, when the column is in edit mode. We can also create a formGroup, that holds a formControl for each row and use it as demonstrated in the following example:
https://stackblitz.com/edit/angular-yfar8j?file=app%2Fapp.component.ts

About the editCell method, by design the grid allows to use it only for a single cell at a time. Thus, using this approach would not be suitable for the requirement.

I hope this points you in the right direction of achieving the desired custom functionality.

Regards,
Svetlin
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Rebekah
Top achievements
Rank 1
answered on 09 Oct 2018, 01:48 PM
Thanks Svetlin! This is exactly what I needed. 
Tags
General Discussions
Asked by
Rebekah
Top achievements
Rank 1
Answers by
Svet
Telerik team
Rebekah
Top achievements
Rank 1
Share this question
or