Textarea in Grid is buggy

1 Answer 466 Views
Grid
Yvette
Top achievements
Rank 1
Yvette asked on 20 Sep 2022, 01:51 PM

hi, I have a simple grid set up for batch mode data entry . Two of the columns need to allow multiline entry (with line breaks) and I thought I had solved this problem by using a textarea. However, it turns out that the textarea is extremely buggy and the errors seem to be completely random and impossible to reliably duplicate. Sometimes it happens when you click into the cell, sometimes when you tab into a cell. After editing the cell contents, the black triangle to indicate an update does not appear in the upper left-hand corner of the column. Upon saving the changes, the data in the column reverts back to the unedited text (the edit is not saved).

I can't find any pattern to this behavior and it usually works fine on the second try.

Is there a better method for allowing multi-line text area in a column?

This is how I have the column set up:

columns.Bound(c => c.PODescription).ClientTemplate("<textarea rows='2' style='border: none; width:100%;'>#=PODescription#</textarea>").Title("*PO Description").EditorTemplateName("TextAreaTemplate").Width("200px");

 

The editor template:

@model string

@(Html.TextAreaFor(m => m, new { rows = 2, @style = "width:100%;" })
)

 

 

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 23 Sep 2022, 08:28 AM

Hello Yvette,

The observed behavior will be expected as there is an editable textarea set as a client template as well as a textarea editor. The ClientTemplate configuration sets the template which renders the column content. As there is no binding set the changes made to that textarea will not be reflected in the model. I can suggest checking this forum post where a similar issue is discussed and testing the approach from the linked knowledgebase article.

In order for the changes to be persisted you can only leave the EditorTemplateName configuration, which indicates which is the Editor Template located in the ~/Views/Shared/EditorTemplates folder that will be rendered as editor.

columns.Bound(c => c.PODescription).Title("*PO Description").EditorTemplateName("TextAreaTemplate").Width("200px");

For additional guidance on implementing custom editors for the Grid I can suggest also referring to the Custom Editing article.

Regards,
Aleksandar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Yvette
Top achievements
Rank 1
Answers by
Aleksandar
Telerik team
Share this question
or