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

Setting properties of selected nodes client side

Hi,

As you might know, I am trying to build a diagram application on my own (i.e., not using your DiagramBuilder sample).

I am trying to do what I think is a simple task - changing some properties of the selected nodes.

From your documentation, the following statement should work:

$("#diagramContent").ejDiagram({ selectedItems: { fillColor: "red" } });

...yet nothing happens when I wire this up to fire off a button control.

I've placed an alert in the function so I know it's being called.

What am I doing wrong?

Thanks

Jim



5 Replies

SG Shyam G Syncfusion Team January 13, 2015 07:23 AM UTC

Hi Jim

Thanks for using Syncfusion products.

Please note that the model selectedItems property should support the properties listed below in the online UG documentation link.

Link: http://help.syncfusion.com/ug/js/documents/selector.htm

Currently we don’t have support for the “fillColor” Property for the “selectedItems” property. We consider this as a feature request and created a new incident 133952 on behalf of you related to this forum. We suggest you to follow up the incident for further reference using your direct trac account

Please let me know if any concerns.

Regards,

Shyam G




JJ Jim Jacobs January 14, 2015 04:23 PM UTC

Hi,

I was able to accomplish what I needed by using the following code:

function ApplyFillColor(sender, eventArgs) {
        var selectedColor = eventArgs.get_value();
        for (var i = 0; i < diagram.model.selectedItems.children.length; i++) {
            var node = diagram.model.selectedItems.children[i];
            diagram.updateNode(node.name, { "fillColor": selectedColor });
        }
    }

But now I have another question for you.
I'm now attempting to change the properties of the label within a node.
I looked at the online documentation and came up with the following code:

    function ComboBoxChanged(sender, eventArgs) {
        var newFontSize = eventArgs.get_comboBox().get_text();
        for (var i = 0; i < diagram.model.selectedItems.children.length; i++) {
            var node = diagram.model.selectedItems.children[i];
            var label = [];
            label = [{ "fontSize": newFontSize }];
            diagram.updateLabel(node.name, node.labels[0], label);
        }
    }

However, nothing happens.
Can you tell me what I am doing wrong.

Many thanks

Jim


SG Shyam G Syncfusion Team January 15, 2015 08:06 AM UTC

Hi Jim

Thanks for using Syncfusion products.

We are glad to inform you that we have created a sample which meets your requirement and it is available in the below link for download. Could you please check in the below sample and get back to us if you are still facing issues at your end?

Code snippet:

<input type="button" value="updatelabel" onclick="updatelabel()" />

function updatelabel() {

            var diagram = $("#Diagram1").ejDiagram("instance");

            var node = diagram.selectionList[0];

            if (node) {

                if (node.labels[0]) {

                    diagram.updateLabel(node.name, node.labels[0], { fontSize: 20, fontColor: "red" });

                }

            }

        }

Sample:http://www.syncfusion.com/downloads/support/directtrac/117944/labelsample-1366371254.zip

Please let me know if any concerns.

Regards,

Shyam G




JJ Jim Jacobs January 15, 2015 11:01 PM UTC

Hi Shyam,

Thanks.

Your code worked.

Jim


SG Shyam G Syncfusion Team January 19, 2015 01:11 PM UTC

Hi Jim

Thanks for the update

Please let us know if you require further assistance on this.

Regards,

Shyam G



Loader.
Live Chat Icon For mobile
Up arrow icon