Simply setting a cell value

5 posts, 0 answers
  1. John
    John avatar
    5 posts
    Member since:
    Jun 2014

    Posted 04 Oct 2015 Link to this post

    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 ?!

  2. John
    John avatar
    5 posts
    Member since:
    Jun 2014

    Posted 05 Oct 2015 Link to this post

    All other questions have been answered - any help please ?
  3. Kendo UI is VS 2017 Ready
  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 06 Oct 2015 Link to this post

    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!
     
  5. John
    John avatar
    5 posts
    Member since:
    Jun 2014

    Posted 06 Oct 2015 in reply to Konstantin Dikov Link to this post

    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....

  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 08 Oct 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready