How to retrieve dataItem of selectedTab

4 posts, 0 answers
  1. Michelle
    Michelle avatar
    33 posts
    Member since:
    Feb 2015

    Posted 26 Feb Link to this post

    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

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 01 Mar Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Michelle
    Michelle avatar
    33 posts
    Member since:
    Feb 2015

    Posted 01 Mar Link to this post

    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

  5. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 03 Mar Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready