简体   繁体   English

渲染部分视图正在TabStrip上书写

[英]Rendering a Partial View is writing over the TabStrip

Why is this overwriting the TabStrip and placing the partial view on top of the TabStrip and not putting it inside one of the tabs? 为什么这会覆盖TabStrip并将部分视图放在TabStrip的顶部,而不是将其放在其中一个选项卡中? I am trying to grab the selected item from a treeview and be able to view a partial view in the tabstrip and have it update as the selection on the treeview changes. 我正在尝试从树视图中获取选定的项目,并能够在选项卡中查看局部视图,并使其随着树视图上的选择更改而更新。 It renders the listview correctly and filters correctly, but now the whole tab control is overwritten by the listview!!!! 它可以正确呈现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>

I had to make a ajax call! 我不得不打一个ajax电话!

Despite that you do not say what is #ContactsTabStrip from the result I guess that it is the identifier of the Tab and not of the body. 尽管您没有从结果中说出#ContactsTabStrip是什么,但我猜它是Tab的标识符,而不是主体的标识符。

Anyway, you don't need to give it a name, you just need to get it from the event argument received in you select handler. 无论如何,您无需为其命名,只需从select处理程序中接收到的事件参数中获取它即可。 Something like this: 像这样:

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);
    });
}

EDIT: If you want to change the content of a Tab different than the selected then first thing is find the index of this tab and then use contentElement for accessing the element. 编辑:如果要更改选项卡的内容与所选内容不同,那么首先要找到该选项卡的索引,然后使用contentElement来访问元素。

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);
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM