Editing in grid react on change event of a control

8 posts, 1 answers
  1. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 11 Jan 2012 Link to this post

    Hello,

    I want to be able to edit in a grid. That is not a problem.
    But for example I have an order line and in a dropdownlist I choose a product.
    On product change want one or more other (editable) fields to be updated, e.g. the product description and price.
    So on product change I want to have an event calling the server and then updating some fields of the row which is currently in edit mode.
    Hope it is a bit clear what I mean.

    Any hints how to do that?

    Thanks, Jaap
  2. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 12 Jan 2012 Link to this post

    Just discovered that a dropdownlist in a grid is not yet supported (will be in the release of this month).
    But that does not change my request:
    On change of a field I want to be able to access and change to whole dataItem which is currently edited.

    Regards, Jaap
  3. Kendo UI is VS 2017 Ready
  4. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 13 Jan 2012 Link to this post

    Just discovered that the grid has a save event which fires after a cell is edited (perhaps cellchanged would be a better name).
    save : function (e) {
        e.model.data.Code = "Changed";
    }

    Here I can change the model. Problem is that the other cell (Code) is not refreshed immediately, but if I do something with the grid which causes the cell to refresh, I can see the change.

    When I read a field from the data, eg:

    Then I get an error:

    Syntax error, unrecognized expression: [data-id=Binnenlandse klanten]

    But it still did the change.

    Sometimes I get also this error: Unable to get value of the property 'editable': object is null or undefined

    But can't reproduce it exactly.

    Any idea what the supposed way to do this is?

    Regards, Jaap
  5. Answer
    Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 13 Jan 2012 Link to this post

    Hi Jaap,

    In order to change Model's value you should use the set method instead modifying its internal data. You may try something similar to the following:

    save: function(e) {
        if (!("Code" in e.values)) {           
            e.model.set("Code", "Changed");
        }
    }

    This will update the appropriate cell in the grid.

    Also note that id values does not support spaces.
    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 13 Jan 2012 Link to this post

    Thank you, that is working.
    It is just the challenge to discover how things should be done. Didn't find this somewhere as example or in the documentation?
    Is there updated documentation available? (Just bought the commercial version this morning).

    But I keep sometimes the error "unrecognized expression: [data-id=Binnenlandse klanten]".
    Now I have the commercial version and so the not minified javascript files, it is must easier to find out what's going on.
    This error occurs in the grid._modelChange where is tried to find the table row with the data-id attribute with a jquery find.
    This gives an error if the model.id() contains invalid characters like space or semicolon. If the id is quoted in the jquery find selector, then it works fine.

    Regards Jaap
  7. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 16 Jan 2012 Link to this post

    Hi Jaap,

    As I have mentioned in my previous message, id field currently cannot contain spaces. However, this limitation may removed in feature versions of the product.

    Regards,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 16 Jan 2012 Link to this post

    Hi Rosen,

    Excuse me, I missed that note from you on the id field.
    As I mentioned in my post it is easy to fix, so I can't imagine it is not fixed in a next release ;-)

    Regards, Jaap
  9. Edwin
    Edwin avatar
    6 posts
    Member since:
    Jan 2012

    Posted 03 Jul 2012 Link to this post

    I have a similar problem with a column defined as
      {
        title: "Remaining",
        template: "#= max_qty - received_qty"
      }

    If I write code to call model.set('received_qty', value), the "Remaining" column is updated without having to call grid.refresh(). However, if I edit the received_qty field with the incell editor, it does not update the "Remaining" column.

    As a workaround, I may be adding a remaining field to the model, so that I can set it. However, I have also found that I have to set that field to editable, or calling model.set('remaining', value) will not refresh the display of that cell.
Back to Top
Kendo UI is VS 2017 Ready