We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Model Update

Hello,
i'm using Syncfusion Diagram 7.4.0.20.
i make two models, and want to switch them.
but there's some problem.

i make the second model, and set that ..
this.diagram1.Model = model2;

and i add an icon, and move it.
the diagram doesn't update view!!

please help me
thank you ~

ben.



ModelUpdate_3f74e94e.rar

6 Replies

MW Melba Winshia Syncfusion Team May 4, 2010 06:23 AM UTC

Hi Ben,

Thank you for contacting Syncfusion Support.

To update model please use the BeginUpdate() and EndUpdate methods.

[C#]

this.diagram1.Model.BeginUpdate();

//Some code here

this.diagram1.Model.EndUpdate();


Please try this and let me know if this helps.

Thanks,
Melba


BW Ben Wang May 5, 2010 02:57 AM UTC

hi:
thanks for your help.

but it doesn't work.
i call the "this.diagram1.Model.BeginUpdate()"
and "this.diagram1.Model.EndUpdate()"
in Model_PinPointChanged Event.

is sumthing wrong? or something need to do for model's setting?



BW Ben Wang May 6, 2010 01:50 AM UTC

hi Melba:

I think i know what's wrong.

i create one node,
and append it to two different models.

can't the node be appedned in different model?

Thanks.


MW Melba Winshia Syncfusion Team May 11, 2010 01:02 PM UTC

Hi Ben,

You can create a node and append it to two different models. Please refer to the following sample which illustrates this:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Diagram_WF_LabelTextNode889079461.zip

Please have a look at the above sample and if still the issue exists, could you please try reproducing in the above sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution?

Thanks,
Melba


BW Ben Wang May 12, 2010 03:07 AM UTC

hi Melba

it still can't work.
the modified sample code is attached.

please click the button and move the icon.

thanks
Ben



Modify_ea67851b.rar


MW Melba Winshia Syncfusion Team May 20, 2010 06:39 AM UTC

Hi Ben,

We regret for the delayed response.

I am able to see this issue. But this issue can be resolved by using AttachModel method. When you attach a new model, only the newModel is set to view.Model. So it renders only the nodes. The newModel is not set to Controller.Model. So you can't interact with the nodes. Because all the interactive functionalities (Select, move, rotate, resize) are integrated into the DiagramController. If you want to interact with the nodes, then you have to assign the attached model to Controller.Model. But Controller.Model is read-only. So you need to derive DiagramController and hide the Model property and then you can write the set accessor. Please refer to the following code snippet:

private void button1_Click(object sender, EventArgs e)
{
this.newdiagram.Model.BeginUpdate();
if (this.newdiagram.Controller.Model == model1)
{
this.newdiagram.AttachModel(model2);
((CustomDiagramController)this.newdiagram.Controller).Model = this.model2;
}
if (this.newdiagram.Controller.Model == model2)
{
this.newdiagram.AttachModel(model2);
((CustomDiagramController)this.newdiagram.Controller).Model = this.model1;
}

this.newdiagram.Model.EndUpdate();

this.newdiagram.Refresh();
}


Please refer to the sample in the following link which illustrates this:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=F94204_ModelUpdate510468238.zip

Please let me know if this helps.

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon