Expanding on initial render

4 posts, 1 answers
  1. Mark
    Mark avatar
    11 posts
    Member since:
    Nov 2015

    Posted 23 Feb Link to this post

    When I set an item to expand on initial render (via .Expanded(true)) I lose formatting.

    I suspect this is because the item loses class "k-state-default" and we have overridden css for this class. I have worked around by adding the class directly:

    panelbar.Add()
        .Text("Expanded Item")
        .HtmlAttributes(new {@class="k-state-default"})
        .Expanded(true)
        .Content(...

    This seems to me to be a bug rather than default behaviour. Why would expanding on initial render be different from expanding via mouse click?

    There is something in kendo.panelbar.js that looks a bit suspicious to me:

    wrapperCssClass: function (group, item) {
        var result = "k-item",
            index = item.index;
     
        if (item.enabled === false) {
            result += " " + DISABLEDCLASS;
        } else if (item.expanded === true) {
            result += " " + ACTIVECLASS;
        } else {
            result += " k-state-default";
        }
     
        if (index === 0) {
            result += " k-first";
        }
     
        if (index == group.length-1) {
            result += " k-last";
        }
     
        if (item.cssClass) {
            result += " " + item.cssClass;
        }
     
        return result;
    },

     

    Can someone confirm if this is a bug or just me being dim.

    Also, is my workaround safe (i.e. it won't interfere with the operation of the control).

    Cheers,

    Mark

     

     

     

     

     

     

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    834 posts

    Posted 25 Feb Link to this post

    Hello Mark,

    The observed is not a bug but expected behavior. The "k-state-active" class is added to an item with Expanded property set to true. This class replaces the "k-state-default" class.
    As for the workaround, it is acceptable, however, instead of using the "k-state-default" we would recommend setting a custom class to the expanded item and using CSS rules with that class as a selector in order to apply the needed styles.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mark
    Mark avatar
    11 posts
    Member since:
    Nov 2015

    Posted 25 Feb in reply to Ivan Danchev Link to this post

    Hi Ivan,

    I should probably clarify why I think this is a problem.

    When the item has Expanded(true) applied initially, the class k-state-active does indeed replace the class k-state-default. Yet, k-state-default never reappears (even when the item is collapsed).

    However, when expanding an item during runtime (not initially), the class k-state-active is added without removing class k-state-default.

    I've tried to illustrate this with a dojo example

     

     

  5. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    834 posts

    Posted 26 Feb Link to this post

    Hello Mark,

    Thank you for the dojo sample.

    We logged this behavior as a bug and we will do our best to fix it as soon as possible. You can use the workaround you have found until a fix becomes available.

    As a token of gratitude for your involvement in identifying this issue I updated your Telerik points.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready