渲染部分视图正在编写TabStrip

时间:2013-11-18 03:29:20

标签: javascript asp.net-mvc asp.net-mvc-4 kendo-ui

为什么这会覆盖TabStrip并将局部视图放在TabStrip的顶部而不是将其放在其中一个标签中?我试图从树视图中获取所选项目,并能够在标签条中查看局部视图,并在树视图上的选择更改时更新它。它正确呈现listview并正确过滤,但现在整个标签控件被listview覆盖了!

<script>
    var treeview;
    $(document).ready(function () {
        treeview = $("#treeview").data("kendoTreeView");
    });
    function select(e) {

        var selectedbook = $(e.node).data("bookid");

        var tabstrip =
        $.get('@Url.Action("Index", "ListView")',
            { id: selectedbook }, function (data) {
                $("#ContactsTabStrip").html(data);
            });
    }
</script>

我不得不拨打ajax电话!

1 个答案:

答案 0 :(得分:1)

尽管你没有从结果中说出#ContactsTabStrip是什么,我猜它是Tab的标识符,而不是正文的标识符。

无论如何,你不需要给它起一个名字,你只需要从你select处理程序中收到的事件参数中获取它。像这样:

function select(e) {
    var selectedbook = $(e.node).data("bookid");

    // Get a reference to the content from the event
    var content = e.contentElement;

    $.get('@Url.Action("Index", "ListView")', { id: selectedbook }, function (data) {
        // Set data
        item.html(data);
    });
}

编辑:如果您想要更改不同于所选内容的选项卡的内容,则首先要找到此选项卡的索引,然后使用contentElement来访问该元素。< / p>

function select(e) {
    var selectedbook = $(e.node).data("bookid");

    $.get('@Url.Action("Index", "ListView")', { id: selectedbook }, function (data) {
        // Get a reference to the tabStrip
        var tabStrip = $("#tabStrip").data("kendoTabStrip");
        // Find the index of the element to be changed
        var idx = tabStrip.tabGroup.find("#ContactsTabStrip").index();
        // Use contentElement function for changing the content
        $(tabStrip.contentElement(idx)).html(data);
    });
}
相关问题