This is a migrated thread and some comments may be shown as answers.

Adding records to grid from external form

1 Answer 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raina
Top achievements
Rank 1
Raina asked on 16 Jul 2020, 05:34 PM

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?

 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 20 Jul 2020, 12:25 PM

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

Tags
Grid
Asked by
Raina
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or