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

Binding issues with Form inside KendoWindow

3 Answers 326 Views
Form
This is a migrated thread and some comments may be shown as answers.
Herrick
Top achievements
Rank 1
Herrick asked on 10 Sep 2020, 08:22 AM

Dear Sir/Madam,

I have a transposed Kendo grid on a page (as described here) where I am trying to mimic the Kendo grid's popup editor using a Form inside a Kendo Window. Clicking an edit button causes a window to be created along with its contained form. This works as expected on the first click since I see the values of the object passed in via the formData property appearing on the form. Submitting the form closes the window and attempts to destroy the form so it can be recreated on subsequent requests to edit the underlying object. Clicking the same edit button a second time should display the same form with its fields populated as the first time. For some reason this is not happening; the fields of the form are blank.

I've replicated the scenario in the following dojo: https://dojo.telerik.com/UsIQijOG

Steps to reproduce:

  1. Click on the "Show Form" button to display a form where the fields are populated
  2. Click on the "Submit" button of the form to close the window
  3. Click on the "Show Form" button to display a form where the fields are blank

Any assistance would be much appreciated. Thank you in advance.

Herrick

3 Answers, 1 is accepted

Sort by
0
Accepted
Petar
Telerik team
answered on 14 Sep 2020, 04:11 AM

Hi Herrick,

The reason for the reported behavior is that when the Form is being destroyed, its DOM element should also be removed or returned to its initial state. In the current context, after the Form is destroyed and the empty method executed, the "#exampleform" has additional attributes left to it which are triggering the behavior demonstrated in the Dojo. 

To implement the targeted functionality we can use the following code:

submit: function(e) {
    e.preventDefault();
    editDialog.close();
    const myForm = $("#exampleform").data("kendoForm");
    myForm.destroy();
    $("#exampleform").remove();
    $("#edit-dialog").append('<form id="exampleform"></form>');
}

The code in yellow is what is changed in this version of the provided Dojo

I hope the provided solution will help you implement the targeted functionality.

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Herrick
Top achievements
Rank 1
answered on 29 Sep 2020, 07:01 AM

Hi Petar,

Thank you very much. Yes indeed, your solution worked!

Regards,

Herrick

0
Petar
Telerik team
answered on 30 Sep 2020, 09:38 AM

Hi Herrick,

I am happy to hear that the suggested approach has helped you resolve the issue in the application you are working on! 

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Form
Asked by
Herrick
Top achievements
Rank 1
Answers by
Petar
Telerik team
Herrick
Top achievements
Rank 1
Share this question
or