Kendo UI TabStrip - 按文本选择选项卡

时间:2022-06-17 14:50:02

I am trying to select a tab in javascript when I only know the Text of the tab

当我只知道选项卡的文本时,我试图在javascript中选择一个选项卡

I know to get the Selected Tab I do this:

我知道要获取Selected Tab我这样做:

var tabStrip = $("#tabMain").data("kendoTabStrip");
var tab = tabStrip.select();

How do I cause the Selected Tab to be the one with the text "MyTitle"

如何使选定的选项卡成为文本“MyTitle”的选项卡

Note: I create the Tab with MVC 4

注意:我使用MVC 4创建了Tab

    @(Html.Kendo().TabStrip()
          .Name("tabMain")
          .Items(items =>
              {
                  items.Add().Text("MyTitle")

4 个解决方案

#1


10  

Basically you need to find the li.k-item and pass it to the select method. Here comes the jQuery:

基本上你需要找到li.k-item并将它传递给select方法。这是jQuery:

var ts = $('#tabstrip').data().kendoTabStrip;
var item = ts.tabGroup.find(':contains("What you look for")');
ts.select(item);

#2


3  

$(document).ready(function(){
      $j("#tabstrip").kendoTabStrip( {
          animation:    {
              open: {
                  effects: "fadein"
              }
          },
    select: function(element){selecttab(element)}           
      });
function selecttab(element) {
        var tabStrip1 = $('#tabstrip').kendoTabStrip().data("kendoTabStrip");
        tabStrip1.select("li:contains(" + $(element.item).text()+ ")");

}            

#3


1  

i tried this - just plain jquery, seems to be working for now in chrome...

我试过这个 - 只是简单的jquery,似乎现在正在使用chrome ...

var selectedTabName = $("li[aria-selected='true']").text();

var selectedTabName = $(“li [aria-selected ='true']”)。text();

#4


0  

The Kendo MVC Server Wrapper exposes the .SelectedIndex(0) method at the tabstrip level and the Selected() method at the individual tab level:

Kendo MVC Server Wrapper在tabstrip级别公开.SelectedIndex(0)方法,在单独的选项卡级别公开Selected()方法:

tabstrip.Add().Text("My Tab") .Selected(someValue = "My Tab")

tabstrip.Add()。Text(“我的标签”).Selected(someValue =“My Tab”)

#1


10  

Basically you need to find the li.k-item and pass it to the select method. Here comes the jQuery:

基本上你需要找到li.k-item并将它传递给select方法。这是jQuery:

var ts = $('#tabstrip').data().kendoTabStrip;
var item = ts.tabGroup.find(':contains("What you look for")');
ts.select(item);

#2


3  

$(document).ready(function(){
      $j("#tabstrip").kendoTabStrip( {
          animation:    {
              open: {
                  effects: "fadein"
              }
          },
    select: function(element){selecttab(element)}           
      });
function selecttab(element) {
        var tabStrip1 = $('#tabstrip').kendoTabStrip().data("kendoTabStrip");
        tabStrip1.select("li:contains(" + $(element.item).text()+ ")");

}            

#3


1  

i tried this - just plain jquery, seems to be working for now in chrome...

我试过这个 - 只是简单的jquery,似乎现在正在使用chrome ...

var selectedTabName = $("li[aria-selected='true']").text();

var selectedTabName = $(“li [aria-selected ='true']”)。text();

#4


0  

The Kendo MVC Server Wrapper exposes the .SelectedIndex(0) method at the tabstrip level and the Selected() method at the individual tab level:

Kendo MVC Server Wrapper在tabstrip级别公开.SelectedIndex(0)方法,在单独的选项卡级别公开Selected()方法:

tabstrip.Add().Text("My Tab") .Selected(someValue = "My Tab")

tabstrip.Add()。Text(“我的标签”).Selected(someValue =“My Tab”)