打开多个窗口剑道菜单 [英] Opening multiple windows with Kendo menu

查看:125
本文介绍了打开多个窗口剑道菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个剑道菜单,我想每一个菜单来打开一个新窗口。我怎样才能做到这一点?

这是我目前的code。在 _layout

 < D​​IV CLASS =K-RTL>
@(Html.Kendo()。菜单()
    。名称(菜单)
    .Items(项目=>
    {
        。items.Add()文本(菜单1)项目(子=>
        {
            child.Add()文本(1)LinkHtmlAttributes(新{的onClick =菜单('1');})。。;
            child.Add()文(2)。
        });
    })
)
< / DIV>
<脚本>
功能菜单(文字){
    VAR窗口= $(#WIN1)的数据(kendoWindow)。
    开关(文字){
        情况1:
            window.refresh({网址:@ Url.Action(索引,1)})。标题(1);
            打破;
        情况下为2:
            window.refresh({网址:@ Url.Action(索引,2)})。标题(2);
            打破;
    }
    的window.open();
}
< / SCRIPT>
 

和我在我的索引创建这个默认的窗口:

  @(Html.Kendo()。窗口()
    。名称(WIN1)
    .title伪(默认)
    .LoadContentFrom(指数,默认)
    .Draggable()
    .Resizable()
    .Actions(行动=> actions.Close()最小化()刷新()。)
    .Position(p值=> p.Top(100))
)
 

我有两个问题,code:

  1. 我想有多个窗口。
  2. 在窗口的刷新按钮加载从previous页面旧的内容。
解决方案

要拥有多个窗口,你可以创建你注入你的HTML code的局部视图( @ Html.Partial( MyGenericWindow)),确保你生成一个新的窗口ID(名称)各一次。

这样的:

  @ {
    VAR WINDOWID = Guid.NewGuid()的ToString()。
}

@(Html.Kendo()。窗口()
    。名称(WINDOWID)
    .Draggable()
    .Resizable()
    .Actions(行动=> actions.Close()最小化()刷新()。)
    .Position(p值=> p.Top(100))
)
 

要解决此问题,刷新试试这个:

 的功能菜单(文字){
    VAR窗口= $(#@ WINDOWID)的数据(kendoWindow)。
    window.title(文本);
    window.refresh({
        网址:@ Url.Action(指数),
        数据:{myParam:文本}
    });

    window.bind(刷新,函数(){
        window.center();
        的window.open();
    });
}
 

I have a kendo menu and I'd like each menu to open a new window. How can I achieve that?

This is my 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 I create this default window in my 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 two problems with this code:

  1. I want to have multiple windows.
  2. Window's refresh button loads the old content from previous page.

解决方案

To have multiple windows you could create a partial view which you inject into your HTML code (@Html.Partial("MyGenericWindow")), ensuring you're generating a 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 the 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();
    });
}

这篇关于打开多个窗口剑道菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆