c# - Opening multiple windows with Kendo menu -
i have kendo menu , i'd each menu open new window. how can achieve that?
this current code in _layout
:
<div class="k-rtl"> @(html.kendo().menu() .name("menu") .items(items => { items.add().text("menu 1").items(child => { child.add().text("1").linkhtmlattributes(new { onclick = "menu('1');" }); child.add().text("2"); }); }) ) </div> <script> function menu(text) { var window = $("#win1").data("kendowindow"); switch (text) { case "1": window.refresh({ url: "@url.action("index", "1")" }).title("1"); break; case "2": window.refresh({ url: "@url.action("index", "2")" }).title("2"); break; } window.open(); } </script>
and create default window in index:
@(html.kendo().window() .name("win1") .title("default") .loadcontentfrom("index", "default") .draggable() .resizable() .actions(actions => actions.close().minimize().refresh()) .position(p => p.top(100)) )
i have 2 problems code:
- i want have multiple windows.
- window's refresh button loads old content previous page.
to have multiple windows create partial view inject html code (@html.partial("mygenericwindow")
), ensuring you're generating new window id (name) each time.
like this:
@{ var windowid = guid.newguid().tostring(); } @(html.kendo().window() .name(windowid ) .draggable() .resizable() .actions(actions => actions.close().minimize().refresh()) .position(p => p.top(100)) )
to fix refresh issue try this:
function menu(text) { var window = $("#@windowid").data("kendowindow"); window.title(text); window.refresh({ url: '@url.action("index")', data: { myparam: text } }); window.bind("refresh", function () { window.center(); window.open(); }); }