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.
Unfortunately, activation email could not send to your email. Please try again.

How to change properties of Text object

Thread ID:

Created:

Updated:

Platform:

Replies:

118065 Jan 27,2015 02:59 PM Feb 3,2015 08:16 AM ASP.NET Web Forms 3
loading
Tags: Diagram
Jim Jacobs
Asked On January 27, 2015 02:59 PM

Hi,

Now that I have the textTool working (thanks for that), I am having trouble trying to change any of its properties.

The following code will successfully change the text color for nodes and connectors, but does nothing for text objects.

function ApplyTextColor(color) {
    for (var i = 0; i < diagram.model.selectedItems.children.length; i++) {
        var object = diagram.model.selectedItems.children[i];
        diagram.updateLabel(object.name, object.labels[0], { fontColor: color });
    }
}

How do I accomplish this for text objects (if that's the correct term) ?

Thanks

Jim

Shyam G [Syncfusion]
Replied On January 28, 2015 04:09 AM

Hi Jim

Thanks for using Syncfusion products.

We suggest you to update the shape's "textblock" property in the "updateLabel" API to update the Text node instead of updating the node's Label. Please see the code snippet below.

Code snippet:

 

function updatelabel() {           

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

            var node = diagram.selectionList[0];

            if (node) {

                if (node.shape.textBlock) {

                    //update text node label

                    diagram.updateLabel(node.name, node.shape.textBlock, { fontSize: 20, fontColor: "red" });

                }

            }

        }

Sample: http://www.syncfusion.com/downloads/support/directtrac/118065/textblock429359551.zip

Please let me know if any concerns.

Regards,

Shyam G



Jim Jacobs
Replied On February 2, 2015 07:38 PM

Hi Shyam,

You got me pointed in the right direction.
I ended up coding the following (which works) to toggle the bold property on/off.

function toggleTextBold() {
    for (var i = 0; i < diagram.model.selectedItems.children.length; i++) {
        var object = diagram.model.selectedItems.children[i];
        if (object.type == 'node') { // A node or a text object
            if (object.shape.type == 'text') { // text object
                if (object.shape.textBlock) {
                    if (object.shape.textBlock.bold) {
                        diagram.updateLabel(object.name, object.shape.textBlock, { bold: !object.shape.textBlock.bold });
                    } else {
                        diagram.updateLabel(object.name, object.shape.textBlock, { bold: true });
                    }
                }
            } else { // node
                if (object.labels[0].bold) {
                    diagram.updateLabel(object.name, object.labels[0], { bold: !object.labels[0].bold });
                } else {
                    diagram.updateLabel(object.name, object.labels[0], { bold: true });
                }
            }
        } else { // Must be a connector
            if (object.labels[0]) {
                if (object.labels[0].bold) {
                    diagram.updateLabel(object.name, object.labels[0], { bold: !object.labels[0].bold });
                } else {
                    diagram.updateLabel(object.name, object.labels[0], { bold: true });
                }
            }
        }
    }
}

Jim

Shyam G [Syncfusion]
Replied On February 3, 2015 08:16 AM

Hi Jim

Thanks for the update

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

Regards,

Shyam G



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;