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

Refresh method with object as parameter

4 Answers 451 Views
Window
This is a migrated thread and some comments may be shown as answers.
JonathanElsner
Top achievements
Rank 1
JonathanElsner asked on 10 Sep 2012, 01:16 PM
function onEdit(e) {
       var id= $(e).attr("data-assumptionid");
        var window = $("#EditAssumptionWindow").data("kendoWindow");
        var assumption = findById(assumptions,id);
 
       window.refresh({
           data: {
               ID: assumption.ID,
               Term : assumption.Term,
               type : assumption.Type,
               unitID : assumption.UnitID,
               Name : assumption.Name
           }
       });
 
       window.open();
       window.center();
   }

Controller method
public ActionResult EditAssumption(Guid  ID, int Term, string Name, string type, int unitID)
        {
            ViewBag.Mode = "Edit";
            AssumptionDTO dto = new AssumptionDTO()
            {
                ID=ID,
                Name=Name,
                Term=Term,
                Type=type,
                UnitID=unitID
            };
            return PartialView("NewAssumption", dto );
        }

I am using the above to refresh the window when the user clicks an item and it works fine.

Is it possible to pass the object itself instead of each parameter individually? like below.  I need to do this because the assumption object is going to have an array that needs to be passed in as a parameter also.  Thanks,

function onEdit(e) {
       var id= $(e).attr("data-assumptionid");
        var window = $("#EditAssumptionWindow").data("kendoWindow");
        var assumption = findById(assumptions,id);
 
       window.refresh({
           data: {
               assumptionDTO: assumption
           }
       });
 
       window.open();
       window.center();
   }

Controller method
public ActionResult EditAssumption(AssumptionDTO dto)
        {
            ViewBag.Mode = "Edit";
            return PartialView("NewAssumption", dto );
        }

4 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 13 Sep 2012, 01:30 PM
Hello Jonathan,

Instead of calling the refresh method with

   data: {
     assumptionDTO: assumption
   }

call it with

    data: assumption

Greetings,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
JonathanElsner
Top achievements
Rank 1
answered on 13 Sep 2012, 01:55 PM
That works except assumption has an array as one of the properties that is not serialized correct.

I need assumption.RentSteps to pass in also.  It passes in but all the properties are null.

Any suggestions?

0
JonathanElsner
Top achievements
Rank 1
answered on 13 Sep 2012, 02:29 PM
I figured it out by using

window.refresh({
            data: JSON.stringify(assumption),
            type: "Post",
            contentType: "application/json"
        });

Is this the correct way? 

Thanks again.
0
Alex Gyoshev
Telerik team
answered on 14 Sep 2012, 11:34 AM
Hello Jonathan,

Yes, this is a valid approach, especially if it posts the data correctly in your case.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Window
Asked by
JonathanElsner
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
JonathanElsner
Top achievements
Rank 1
Share this question
or