Core Grid responsive columns bind value to input

1 Answer 270 Views
Grid
Samuel
Top achievements
Rank 1
Samuel asked on 06 Jul 2021, 01:46 PM

How you do bind a value to an input when using a responsive columns template? The value wont be saved from the input when trying to save. E.G: Row is added, I edit the value, but when I save, it goes back to 0.

 


        columns.Template("#=resColTemplate(data)#").Title("Items").Media("(max-width: 475px)");


<script id="responsive-column-template" type="text/x-kendo-template">
    <strong>Amount</strong>
    <p class="col-template-val">
        <input class="numeric" data-bind="#: Amount #" value="#: Amount#" required />
    </p>
</script>

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 09 Jul 2021, 07:17 AM

Hi, Samuel,

When the editor templates are inside the ClientTemplate, they are not automatically bound to the underlying data item. Therefore, any changes inside the ClientTemplate will not be reflected in the data source of the widget.

What I can recommend is that you subscribe to the DataBound event of the grid, within the handler loop through all rows and gather their corresponding data items via:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/dataitem

After you have a reference to the row element and to the data item, make use of the kendo.bind() method where you will pass the row and the data item and it would bind them. Hence any changes will be reflected in the data item:

https://docs.telerik.com/kendo-ui/api/javascript/kendo/methods/bind

Let me know if additional information is required.

 

Regards,
Tsvetomir
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/.

Tags
Grid
Asked by
Samuel
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or