asp.net - Kendo UI Grid in MVC - How to return selected row Item to Controller -
i have mvc 4 application kendo ui grid using user management. display users information in grid , have custom command button when clicked opens new page edit users information. various reasons (one being there information edited display in grid) need edit users on new page , not inline or popup or incell editing. grid looks this... simple
@(html.kendo().grid<websitenew.models.manageusersviewmodel>() .name("grid") .htmlattributes(new { style = "margin-top: 5px" }) .columns(c => { c.bound(model => model.username); c.bound(model => model.firstname); c.bound(model => model.lastname); c.bound(model => model.email); c.bound(model => model.phone); c.bound(model => model.extension); c.bound(model => model.jobtitle); c.command(com => { com.custom("edit").click("edit"); com.destroy(); }); }) .pageable() .sortable() .selectable() .datasource(d => d .ajax() .pagesize(20) .model(m => m.id(i => i.username)) .read(r => r.action("manageusers_read", "manageusers")) .destroy(o => o.action("manageusers_destroy", "manageusers")) ))
the issue have here need pass id of user edit button has been clicked on edit screen can bring information selected user. way know of information through javascript, in command button click function...
function edit() { var grid = $("#grid").data("kendogrid"); var row = grid.select(); var dataitem = grid.dataitem(row); var id = dataitem.userid; location = "@url.action("edituser")"; }
this gives me id need have no way (that know of) pass controller. question is... how information server side? there way information need or not possible in kendo ui mvc?
to make more general question.. when @ kendo ui documentation , tells me how value in javascript... how, in general, 1 go using value in mvc application when needed on server side? can't seem find alternative "mvc" way in documentation.
you should form additional parameters url string:
location = "@url.action("edituser")" + "?id="+id;
Comments
Post a Comment