Simply setting a cell value

1 Answer 7796 Views
Grid
John
Top achievements
Rank 2
John asked on 04 Oct 2015, 11:03 PM

I have a grid with 5 columns - COL1 to COL5. I call a function when the user selects a row and chooses a menu option from a context menu. The function gets the selected row. All I want to do is set the text of a certain column in the selected row:

 

    var grd = $(gridCTL).data('kendoGrid');
    var selectedItem = grd.dataItem(grd.select());

    selectedItem.COL1 = "new value"; // this does not work

 

Can anyone help with this simple task ?!

John
Top achievements
Rank 2
commented on 05 Oct 2015, 03:31 PM

All other questions have been answered - any help please ?

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 06 Oct 2015, 12:05 PM
Hello John,

If you want to change a value through the data item you should use the set("fieldName", "newValue") method:
In the context of your code snippet, following is the correct way for changing the value:
selectedItem.set("COL1", "new value");

Hope this helps.

 

Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
John
Top achievements
Rank 2
commented on 06 Oct 2015, 12:47 PM

It's interesting that you change the data source to make a change to the cell text. I didn't see anywhere in the documentation that the row will automatically update the UI when the data changed.

 Telerik need to put more detail into the demos, as they only cover the basics....

Konstantin Dikov
Telerik team
commented on 08 Oct 2015, 06:40 AM

Hi John,

If you use Batch editing, you should be able to open the cell for editing, change the value and manually blur the input editor in the cell, which will make the cell dirty and will allow you to save the changes only after you finish with the editing. In any other case you will have to update the model, which will then update the grid.


Kind Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Kate
Top achievements
Rank 1
commented on 25 Oct 2019, 08:10 PM

How do you manually blur the input editor? using .blur() in jQuery doesn't seem to have any effect.
Petar
Telerik team
commented on 28 Oct 2019, 04:16 PM

Hi Kate,

As the current thread is an old one, can you please give me more details about the functionality you want to achieve? I can see that you have an active license and you can also submit a support thread. 

If you want to continue the discussion here, give me more details about the desired functionality.

Regards,
Petar
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.
Kate
Top achievements
Rank 1
commented on 28 Oct 2019, 09:07 PM

Hi Petar,

I was able to find an answer to this on stackoverflow here (https://stackoverflow.com/questions/41439122/how-to-manually-set-column-value-in-kendo-grid). It's not the post marked as the answer, but I used the post underneath the one marked as answer:

    Always use set() method from the Model to change values. No need to refresh(), e.g.:
var dataItem = $("#grid").data("kendoGrid").dataSource.data()[0]; dataItem.set("reason", "new value");

Petar
Telerik team
commented on 29 Oct 2019, 08:40 AM

Hi Kate,

I am happy to hear that you've managed to resolve the issue! Thank you for sharing the solution with the community.

Regards,
Petar
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.
Tags
Grid
Asked by
John
Top achievements
Rank 2
Answers by
Konstantin Dikov
Telerik team
Share this question
or