This is a migrated thread and some comments may be shown as answers.

How to retrieve dataItem of selectedTab

3 Answers 271 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Michelle
Top achievements
Rank 1
Michelle asked on 26 Feb 2016, 07:36 PM

Hi,

I have a tabstrip that has a dataSource with an array of items.  I also use the dataContentField to specify which property in the dataItem contains the content HTML.  The tabs are binding correctly and rendering the correct tab contents dynamically.  Now, I need to figure out which tab is selected and which dataItem is bound to the selected tab so that I can add a new dataItem in the dataSource after the selected tab's dataItem.  Theoretically, this will trigger the tabstrip to dynamically generate a new tab after the selected tab.  I am using tabstrip.select(), but that just gives me the element.  I tried to use tabstrip.dataItem(tabstrip.select()), but dataItem doesn't seem to exist on tabstrip, unlike other widgets like Grid etc.  How can I get the dataItem from a selected tab element?  It would also work if I can get the index of the selected tab element, but that is less elegant.

Thanks,

Michelle

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 01 Mar 2016, 03:19 PM

Hello Michelle,

 

The Kendo UI TabStrip does not have a dataItem method. My suggestion is to use the insertAfter method that inserts a newly-created tab after a specified tab.

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Michelle
Top achievements
Rank 1
answered on 01 Mar 2016, 09:51 PM

Hi Boyan,

Please note that in my first message I mentioned that I'm using a dataSource.  If I use insertAfter to manually add a tab, it would not match with the dataSource.  If you are suggesting that I should add it to my dataSource and I should also add the tab manually to match the dataSource, I feel it defeats the purpose of having a dataSource, which is supposed to dynamically generate tabs for me.  Also, even if I add both to dataSource and to tab manually, I still require the dataItem of the selected tab because I need information in there in order to generate the new tab.  My tabs are highly dynamic and they are powered by data.  The fact that the widget supports a dataSource means that it needs to have a dataItem method to map elements to its data.  Otherwise, it is very hard to reliably control the widget through data manipulation.

As a side note, I was able to find the index of the selected tab using the tabStrip.items array and I was able to retrieve the data item by accessing the data source using that index.  However, that is not very elegant and I would much prefer to use a dataItem method, which is available on other widgets that support dataSource.

 

Thanks,

Michelle

0
Petyo
Telerik team
answered on 03 Mar 2016, 01:18 PM
Hello Michelle,

thank you for your feedback. I am in a complete agreement with you - the entire TabStrip API is based on jQuery concepts and is far from convenient in data bound scenarios. We are taking this into account for our current development effort.  

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TabStrip
Asked by
Michelle
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Michelle
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or