Adding records to grid from external form

2 posts, 0 answers
  1. Matt
    Matt avatar
    1 posts
    Member since:
    Nov 2017

    Posted 16 Jul 2020 Link to this post

    I've looked around and seen many examples about how to edit records within a grid via an external form, and I've got that all up and running without incident.

    but I also need to allow users to add new records to this grid as well.  can this be accomplished?  I don't want to use popup or inline editing when creating new records, and then have a different mechanism for editing existing records since this will be confusing.

     

    using inline editing as an example, sort of works, in that, I can click create, a new row is created, I then click that row, and the external edit form will let me update some fields, but not all (https://dojo.telerik.com/eYUfiRuZ) and this solution is far from ideal, unless I can get the newly created row to be the default selection when the create button is selected.

     

    Any thoughts?

     

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2153 posts

    Posted 20 Jul 2020 Link to this post

    Hello Matt,

    You can select the newly added row with the Grid's select method:

    edit: function(e) {
      e.preventDefault();
      if (!e.model.isNew()) {
        // Disable the editor of the "id" column when editing data items
        var numeric = e.container.find("input[name=id]").data("kendoNumericTextBox");
        numeric.enable(false);
      }
      else {
        this.select("tr:eq(0)");
      }
    }

    The updated dojo example: https://dojo.telerik.com/eYUfiRuZ/3

    Regards,
    Ivan Danchev
    Progress Telerik

Back to Top