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

Binding data to popup window

3 Answers 1009 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 15 Jun 2017, 09:44 PM

I have an MVC page that is displaying certain data via a series of observable variables (or actually properties since it's an viewModel object).  All simple stuff as it relates to MVVM really.  Everything works really well.  Change the value of the variable, and the data in the appropriate spans within the page updates automagically.  Love it.

However, now I'm adding a Kendo Window, initially not visible when the page loads.  When the user presses a button, I want the window to open with a form for editing the data.  I've added the appropriate html inputs, and also added the data binding on the control to the same MVVM variables used to display on the page, but when I open the dialog, the data isn't populated with the MVVM variables that are otherwise displaying a-ok on the screen.

Sure, upon the opening of the window, I could use jQuery to populate the form, but I wanted to use the bound MVVM variables.

So is there a trick to this?  I'm no stranger to the concept of MVVM having used Knockout for a long while before switching to the Telerik MVVM.  I've been using it for close to a year, but always just to display data updates on a screen via an ajax call.  (after an AJAX call, setting the appropriate viewModel properties, and they update on the bound spans within the page).

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 19 Jun 2017, 11:02 AM

Hello Joe,

Eventually in order to help you in more efficient way we would need an example that shows the described problem. For example there is a Edit Records Using External Forms that shows how to use a completely separate form using MVVM to edit records in the Kendo UI Grid. Could you please modify or prepare a new sample to replicate the problem? 

Regards,
Boyan Dimitrov
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.
0
Riley
Top achievements
Rank 1
answered on 22 Feb 2021, 07:57 PM

Boyan,

I'm going to second what Joe has requested (many years later).

Using your example - how would you make the form into a popup window, binding the data from the grid to the window, and opening the window by clicking a button in the grid? And do this using an MVVM structure (eg. data-bind="data: myData") for the entirety of the fields within the window. The example you provided does not use an MVVM structure to do so, but relies on jQuery which is something Joe (and I) didn't want to have to do.

All examples of the popup window I've seen have not been bound to data - even the MVVM popup example is based on a template with hardcoded data. What Joe and I are asking for is an example on how to bind data to the popup window within the view using a 'data-' tag.

0
Ianko
Telerik team
answered on 25 Feb 2021, 12:08 PM

Hi Riley,

The scenario highlight demands some custom code implementation as the content of the window is not template-able by design and it cannot be dynamically set via observables. 

However here you are a solution with a custom binder that may help you out further on implementing what you require. https://dojo.telerik.com/@iankodj/ElEVOBOT 

Regards,
Ianko
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/.

Tags
MVVM
Asked by
Joe
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Riley
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or