简体   繁体   English

如何获取Kendo UI TabStrip中当前选定选项卡的引用?

[英]How do I get a reference to the currently selected tab in a Kendo UI TabStrip?

I'm creating a method to delete a Kendo UI TabStrip Tab based on an 'x' image. 我正在创建一种方法来删除基于“x”图像的Kendo UI TabStrip选项卡。 I want it to work in the same way as other tab controls (such as Chrome/IE): 我想让它以与其他标签控件(例如Chrome / IE)相同的方式工作:

  • If the active tab is closed then select the next tab (or if it's the last tab then select previous tab). 如果活动选项卡已关闭,则选择下一个选项卡(如果它是最后一个选项卡,则选择上一个选项卡)。
  • If it's not an active tab then ensure the active tab remains open. 如果它不是活动选项卡,请确保活动选项卡保持打开状态。

I believe I need to get a reference to the current tab, then check if the tab being deleted is the active tab. 我相信我需要获取对当前选项卡的引用,然后检查被删除的选项卡是否为活动选项卡。

My code at the moment simply closes the tab in relation to the clicked image: 我的代码目前只是关闭与点击图像相关的标签:

function DeleteTab(imgObj) {

        var tabStrip = $("#tabstrip").data("kendoTabStrip");

        var deleteIndex = $(imgObj).closest("li").index();
        tabStrip.remove(deleteIndex);
}

How do I get a reference to the currently selected tab? 如何获取当前所选选项卡的引用? Can I do this by searching for k-state-active ? 我可以通过搜索k-state-active来做到这一点吗?

tabstrip.select()将返回当前选定的选项卡。

tabStrip.select().index();

将返回当前选中的选项卡索引

To get the currently selected tab of the tabstrip, you can use: 要获取tabstrip的当前选定选项卡,您可以使用:

var selectedTabElem = $("#tabstripElemId").data('kendoTabStrip').select();// this will be the <li> element that is currently selected

Then one can access the current tab text as below: 然后可以访问当前标签文本,如下所示:

var currentSelectedTabText = $(selectedTabElem).children(".k-link").text();

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

相关问题 如何在Kendo UI中使用其选定的tabIndex重命名当前选定的标签 - How to rename currently selected tab using its tabIndex in kendo UI 如何使用angularJS激活Kendo UI tabstrip的第二个选项卡 - how to activate second tab of Kendo UI tabstrip using angularJS 如何从Kendo UI操作表中获取所选项目? - How do i get the selected item from kendo UI actionsheet? jQuery UI 标签 - 如何获取当前选择的标签索引 - jQuery UI Tabs - How to Get Currently Selected Tab Index Kendo UI-如何引用控件? - Kendo UI - how do I reference a control? 在Telerik TabStrip(MVC)中,如何获取选定的标签索引? - In Telerik TabStrip (MVC), how to get the selected tab index? 如何正确到达数组的开头或结尾? 如何传递当前所选项目的参考? - How do I get to the beginning or end of the array properly? How do I pass in a reference of currently selected item? 如何隐藏*单个* MVC/Kendo tabstrip 选项卡? - How to hide a *single* MVC/Kendo tabstrip tab? Kendo UI - 如何使用javascript添加和选择一个新的Tab(在TabStrip控件上) - Kendo UI - How to add AND select a new Tab (on TabStrip control) using javascript 嵌套在Kendo网格中时如何重新加载Kendo TabStrip选项卡 - How do I Reload the Kendo TabStrip Tabs when Nested in a Kendo Grid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM