asp.net mvc 3 - How to pass an object from a View to a Partial View within a popup window? -


i have view containing telerik grid:

index.cshtml

@(html.telerik().grid(model) .name("grid") .datakeys(keys => keys.add(c => c.customerid)) .toolbar(toolbar => toolbar.template(         @<text>             <button id="feedback-open-button" title="add customer" class="t-button t-state-default">add</button>         </text>)) .columns(columns =>         {                columns.autogenerate(column =>                 {                     //customize autogenereted column's settings                     column.width = "150px";                                                                         if (column.member == "customerid")                         column.visible = false;                 });             columns.command(commands => commands                 .custom("editcustomer")                 .text("edit")                 .dataroutevalues(route => route.add(o => o.customerid).routekey("customerid"))                 .ajax(true)                 .action("editcustomer", "grid"))             .htmlattributes(new { style = "text-align: center" })             .width(150);         })     ) 

i want add/edit records grid using popup. have used telerik window, in have opened view partial view add/edit records. code window , how opening popup "add functionality".

index.cshtml

@{  html.telerik().window()     .name("window")     .title("add / edit customer")             .content(@<text>                                          @html.partial("addeditcustomer", new customer());              </text>)     .width(400)     .draggable(true)     .modal(true)     .visible(false)     .render(); }   @{ html.telerik().scriptregistrar()     .ondocumentready(@<text>         // open hidden window when button clicked         $('#feedback-open-button')             .click(function(e) {                 e.preventdefault();                 $('#window').data('twindow').center().open();             });                                </text>); } 

i have tried use same window edit. having problem in passing customer object partial view within window.

customercontroller.cs

public jsonresult editcustomer(int customerid) {     var model = customermodel._customercollection.firstordefault(o => o.customerid == customerid);      return json(new { customer = model }); } 

index.cshtml

<script type="text/javascript"> function oncomplete(e) {     if (e.name == "editcustomer") {        var detailwindow = $("#window").data("twindow");               var customer = e.response.customer;                                detailwindow.center().open();     }  } </script>    

how can pass "customer" object partial view inside popup window?

the way deal work creating empty div in telerik window. "edit" link ajax link uses window's div target. link calls controller method of choice, , there rather returning json, return partialview want displayed. benefit of approach use customer object normal view/partial.

after ajax completes, open telerik window , content should there.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -