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

Send grid data to kendo window with MVC controller

1 Answer 866 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 20 Jul 2018, 05:18 PM

I want to open a kendo window with the data from a grid on the same page. I've done this with single selected items, but not with the list of items in the grid.

What's the proper method to serialize the data?

Here is some code

 

controller

public PartialViewResult WindowPartialView(IEnumerable<MyGridModel> models)
          
            return PartialView(models);
        }

in window

.LoadContentFrom("WindowPartialView""MyController")

 

function openPlacardWindow() {
  
     debugger;
     var grid = $("#MyGrid").data("kendoGrid");
     var gridData = grid.dataSource.data();
  
     
     var win = $('#myWindow').data("kendoWindow");
     win.refresh({ data: gridData }); //not correct
     win.center();
     win.open();
  
 }

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 24 Jul 2018, 01:08 PM
Hello,

The refresh method of Kendo Window is using data in a similar way as jQuery ajax would do this. In such case one way to send an array is to use JSON.stringify and expected the data with a variable with the same parameter. Here is the data that worked correctly at my side for sending some dummy data:
var dataSource = new kendo.data.DataSource({
               data: [
                   { name: "Jane Doe" },
                   { name: "John Doe" }
               ]
           });
 
           dataSource.fetch(function () {
               var gridData = dataSource.data();
               var win = $('#myWindow').data("kendoWindow");
 
               win.refresh({
                   datatype: 'json',
                   data: {
                       gritData: JSON.stringify(gridData)
                   }
               }); //not correct
               win.center();
               win.open();
           });
public ActionResult DummyMethod(string gritData)
{
    return PartialView(gritData);
}

You will have to deserialize the gridData on the server side so you could refer to one of the suggestions in this forum thread.

Hope this information will be helpful. If you have further questions please let me know.

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