Ian Vink
Ian Vink

Reputation: 68750

Kendo UI TabStrip - Selecting a tab by it's Text

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

I know to get the Selected Tab I do this:

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

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

Note: I create the Tab with MVC 4

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

Upvotes: 6

Views: 17347

Answers (4)

Kcats Wolfrevo
Kcats Wolfrevo

Reputation: 813

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

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

Upvotes: 1

Mayur Kukadiya
Mayur Kukadiya

Reputation: 994

$(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()+ ")");

}            

Upvotes: 3

Petur Subev
Petur Subev

Reputation: 20203

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

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

Upvotes: 11

Sabu's Lead Coder
Sabu's Lead Coder

Reputation: 175

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

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

Upvotes: 0

Related Questions