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

Tracking expand/collapse

3 Answers 85 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Simon Wolters
Top achievements
Rank 1
Simon Wolters asked on 30 Aug 2010, 05:41 PM
Hi,

I am trying to track clientside expanding/collapsing as ClientOperations, for example:

function OnClientItemExpand(sender, args) {
    var panel = sender;
    var item = args.get_item();
 
    if (item && panel) {
        panel.trackChanges();
        item.expand();
        panel.commitChanges();
    }
    else {
        alert("item or panel is null");
    }
}

Unfortunately expand and collapse don't seem to be tracked by the trackChanges() function. Therefore after a postback the serverside collection RadPanelBar.ClientChanges is empty. My example works fine if I use disable() or other functions instead of expand().

Is there any way to track expand/collapse as well? Can I somehow add custom changes to the ClientChanges collection from JS?
My goal is simply to see clientside changes in the expand/collapse state after a postback on the serverside, too.

Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 30 Aug 2010, 07:19 PM
Hi Simon Wolters,

I guess, you don't need the entire history of expand/collapse, instead you need the final state before post back or ajax request, right?
If this is your case, you can use the PersistStateInCookie property of the RadPanelBar.

Hope this is going to help you!


Regards,
Nikolay Tsenkov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Simon Wolters
Top achievements
Rank 1
answered on 30 Aug 2010, 07:32 PM
Not exactly. I really need to know which items actually changed their state clientside because I need to set a property in an underlying ViewModel on the serverside. 

Image the following scenario: When the user first requests the page, the PanelBar is initialized and expands certain PanelItems. The underlying ViewModel for these items determines if each item is expanded or collapsed using a boolean property "IsExpanded". Now, if the user collapses an item clientside, I want the ViewModel to notify this and change its IsExpanded property to false (like two-way databinding in Silverlight or WPF). Since there is no postback after his actual collapsing operation (and there shouldn't be one), I guess my chance to catch the changes is after the next postback - whatever triggered it. So my idea was to save all changes using JS, evaluate them in Page_Load or Page_PreRender and then set the ViewModel properties accordingly.
It would probably also help if the control exposed its whole final state serverside. 

I do know that the ViewModel state idea is rather uncommon for an ASP.NET WebForm but I am evaluating the MVVM concept for ASP.NET in my bachelor thesis prototyping an existing Silverlight application which uses this pattern. 
0
Nikolay Tsenkov
Telerik team
answered on 01 Sep 2010, 11:31 AM
Hello Simon Wolters,

The reason that we introduced this action log is simply to save performance from constant post-back (where needed), batching the action execution in a single less often post-backs.

What is meant by "where needed":
- Imagine, that you have a panelBar with just 3 root elements. And there is no unique identification for any of them (no value, text etc. that you can rely on its uniqueness), only the position makes it unique. What if, on the client you do the following:
1. Delete Item0;
2. Change the name of Item1 to the one previously possessed by Item0;
3. Post-back;
4. On the server, how can you determine, what happened?
There isn't a way to do so and this is example scenario, where this functionality is needed. That's why you can log the actions and then execute them on the server, making possible for you to know which element is which element.

Now, you need to apply the Expanded state to your data-model. You know the structure of items, because you executed (read) the log. All you need to do, in order to apply the Expanded state (and what I meant, by "you don't need the entire history of expand/collapse" is that your model, doesn't possess the different stages of the history, right? It only keeps the current state), you need only to directly look at the current state (again, you know the structure: firstNode->deleted=>firstNodeModelEntity->deleted; secondNode->becomesFirstNode=>firstNode=secondNode; firstNode.Name="...." and so on, and so on. And finally, what is the firstNodeModelEntity.Expanded=firstNode.Expanded).

After all, there is chance that I didn't understood your scenario correctly. Please, if this is the case, explain it in a bit more detail for me and I will do my best to help you resolve the problem!

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
PanelBar
Asked by
Simon Wolters
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Simon Wolters
Top achievements
Rank 1
Share this question
or