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

Popup Editor - overriding Update

1 Answer 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 15 Sep 2017, 10:30 PM

How can I intercept the Update button press on the popup editor?

I don't like using the Html Model "For" helpers, instead I'm a bit old school where I use javascript to populate my form before it shows.  Because of this, when I Add or Edit a record, obviously the model isnt populated with the form field values.  So how I can detect when the Update button was pressed for either an Add or Edit, and so I can collect the values programmatically to pass to the MVC action for Edit / Create?

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 19 Sep 2017, 01:20 PM
Hi Joe,

Have in mind that that the names of the inputs must match the names of the properties of the data model. If they match, all fields of the model will bind automatically to the values of the inputs.

However, possible solution to manually set the values is to add event handler to the input and when it changes, change the value in the model:

Attach event handler:

.Events(x=> x.Edit("onEdit"))

Event handler logic:

 
function onEdit(e) {
 
    e.container.find('#nameOfField').on('change', function () {
             
        e.model.set("nameOfField", this.value);
        console.log(e.model);
    })
}

Attached you will find a small sample illustrating the aforementioned approach.


Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Joe
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or