Quote:Slavcho wrote on Nov 2
nd, 2016 at 3:10pm:
Quote:Can I set node size through server side, like register event?
With latest build of the script, you could set Bounds on server side, and set IconSize and DefaultNodeSize values of the NodeListView to null from client side, to make it use nodes' Bounds instead. We should have updated version of the .NET assemblies that will let you do that entirely from server side later today or tomorrow.
I need to set the shapeNode size when dragAndDroping the ShapeNode, I tried registering server-side event but it didn't work, it only worked if I set the JS event,
so it's not available on server-side, or I am doing something wrong?
Quote:Slavcho wrote on Nov 2
nd, 2016 at 3:10pm:
Quote: I have custom property ShapeType
Check if your JavaScriptConverter code gets called (the one you register with RegisterConverters) - it's where the custom property should be serialized to send to client side. You must also override fromJson in JavaScript to read it.
Yes converter gets called: Quote: I checked serialization and seems that ShapeType is added to json Dictionary, but there is no value in the end.
It gets correct object type in javascript when I use "node.getType();"
What I did wrong?, I almost all the code is copied from Mindfusion sample IconNode,
but I just set the value of the property in the .cs.
Converter Code: public class MyShapeNodeConverter : ShapeNodeConverter
{
public MyShapeNodeConverter (DiagramView view) : base(view)
{
}
public MyShapeNodeConverter (DiagramView view, bool addInstanceId) : base(view, addInstanceId)
{
}
public override IEnumerable<Type> SupportedTypes
{
get
{
return new List<Type>(new[] { typeof(DLXShapeNode) });
}
}
public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
{
var customNode = (MyShapeNode)base.Deserialize(dictionary, type, serializer);
return customNode;
}
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
{
var shapeNode = obj as MyShapeNode;
if (shapeNode == null)
return null;
var json = base.Serialize(obj, serializer);
if (json == null)
return null;
json.Add("ShapeType", shapeNode.ShapeType);
return json;
}
}
JS class: MyShapeNode = function () {
MyShapeNode.initializeBase(this);
}
MyShapeNode.prototype =
{
initialize: function () {
MyShapeNode.callBaseMethod(this, 'initialize');
},
dispose: function () {
MyShapeNode.callBaseMethod(this, 'dispose');
},
//properties
getTitle: function() {
return this.Title;
},
setTitle: function(value) {
if (this.Title !== value)
this.Title = value;
},
getEmailSubject: function () {
return this.EmailSubject;
},
setEmailSubject: function (value) {
if (this.EmailSubject !== value)
this.EmailSubject = value;
},
getShapeType: function () {
return this.ShapeType;
},
setShapeType: function (value) {
if (this.ShapeType !== value)
this.ShapeType = value;
},
getEmailBody: function () {
return this.EmailBody;
},
setEmailBody: function (value) {
if (this.EmailBody !== value)
this.EmailBody = value;
},
getDescription: function () {
return this.Description;
},
setDescription: function (value) {
if (this.Description !== value)
this.Description = value;
},
toJson: function () {
var data = MyShapeNode.callBaseMethod(this, "toJson");
data.Title = this.Title;
data.EmailSubject = this.EmailSubject;
data.EmailBody = this.EmailBody;
data.ShapeType = this.ShapeType;
data.Description = this.Description;
data.nodeType = this.nodeType;
return data;
},
fromJson: function (json) {
MyShapeNode.callBaseMethod(this, "fromJson", [json]);
this.setTitle(json.Title);
this.setShapeType(json.ShapeType);
this.setEmailSubject(json.EmailSubject);
this.setEmailBody(json.EmailSubject);
this.setDescription(json.Description);
return json;
},
updateCanvasElements: function (node) {
MyShapeNode.callBaseMethod(this, 'updateCanvasElements');
}
};
if (typeof (Sys) !== 'undefined')
Sys.Application.notifyScriptLoaded();
My testing script: function onNodeCreated(sender, args) {
var node = args.getNode();
alert(node.getShapeType());
}