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

Expanding on initial render

3 Answers 96 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Feb 2016, 04:20 PM

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

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 25 Feb 2016, 02:23 PM
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
0
Mark
Top achievements
Rank 1
answered on 25 Feb 2016, 03:34 PM

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

 

 

0
Accepted
Ivan Danchev
Telerik team
answered on 26 Feb 2016, 04:08 PM
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
Tags
PanelBar
Asked by
Mark
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or