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

Non-docked Docks cloned plus Invalid JSON primitive

3 Answers 120 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Fergus Bown
Top achievements
Rank 1
Fergus Bown asked on 11 Feb 2009, 06:27 PM
I have a set of dock zones with docks in them. Some docks are added via postbacks as per you examples.

When
1. a Dock as been undocked by a user and dragged elsewhere, and
2. a postback occurs (even if no event handler is called)
The undocked dock is cloned. If the user drags it it reveals another copy of it which was beneath it.

If then
3. a second postback occurs (even if no event handler is called)

Then I get:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Invalid JSON primitive: {"Top":309,"Left":302,"DockZoneID":"","Collapsed":false,"Pinned":false,"Resizable":true,"Closed":false,"Width":"47%","Height":null,"ExpandedHeight":0,"Index":0}.

I think I've narrowed it down to the Page_Init code as per your sample

 

List<DockState> currentDockStates = CurrentDockStates;

 

 

for (int i = 0; i < currentDockStates.Count; i++)

 

{

 

RadDock dock = new RadDock();

 

dock.ID =

string.Format("ChartDock{0}", i);

 

dock.ApplyState(currentDockStates[i]);

RadDockLayout1.Controls.Add(dock);

LoadWidget(dock);

}

but  am at a loss as to how to fix it.
Do you have any suggestions?

thanks

3 Answers, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 12 Feb 2009, 09:36 AM
This error appears ifyou try to update RadDocks via AJAX. If I am right please read the following:
"The problem you experience is due to that you update a floating RadDock with AJAX. When dragging the dock you move it outside the update panel and this causes AJAX not working properly as it attempts to recreate the dock at the place it was previously located and the dock is moved at the new place and stays there. In this way two docks with the same id appear on the page and this leads to an exception."

Several examples which illustrates how to update RadDock via ajax are available here:
http://demos.telerik.com/aspnet-ajax/dock/examples/autopostback/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx
e.g. On every ajax call you should update all RadDockZones while all RadDocks are docked(not floating)

If your problem is different please paste the entire page source, and I'll try to help you.
0
Fergus Bown
Top achievements
Rank 1
answered on 12 Feb 2009, 12:23 PM
It seems as though it probably is. But I don't quite understand this sentence of yours:
'e.g. On every ajax call you should update all RadDockZones while all RadDocks are docked(not floating)'
What do you mean by 'while'?

Do you mean that I should never perform a postback while there are floating RadDocks?
Do you mean that I should re-dock all RadDocks before posting back?
Do you mean that I should not update non-docked RadDocks on the postback?

Re your samples.
The first sample doesn't show on-the-fly dock creation, and therefore (?) does not have Page_Init code to induce the cloning error.

Every time I have tried I have failed to get the second sample (repositioning via javascript) working in my application. I always get a null reference within the AJAX javascript. So I've resorted to the simple add-directly-to-a-dock mechanism.

cheers
0
Petio Petkov
Telerik team
answered on 13 Feb 2009, 04:07 PM
Hi Fergus Bown,

The RadDock control is not a standard control and there are some limitations when it is updated via ajax.
If you want to update a RadDock via ajax you should update all RadDockZones and all RadDocks should be docked.

The error you experience is due to that you update a floating RadDock with AJAX. When dragging the dock you move it outside the update panel and this causes AJAX not working properly as it attempts to recreate the dock at the place it was previously located. In this way two docks with the same id appear on the page and this leads to an exception. This is a common problem for all controls which could be moved in the DOM.

There is another approach which we illustrated in the MyPortal example.
 
If you still experience problems implementing this logic, please open a new support thread and send us a project and detailed description of your goals. Once we receive it we will do our best to help you.

Greetings,
Petio Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Dock
Asked by
Fergus Bown
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Fergus Bown
Top achievements
Rank 1
Petio Petkov
Telerik team
Share this question
or