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

How to determine # of objects selected

Hi,

I need to know if:
  • 1 object is selected
  • >1 object is selected
  • No objects are selected

I am using the following in several functions within my app, and it seems to be working fine:

diagram.model.selectedItems.children.length

However, when I use this in the OnClientSelectionChange event handler, I get strange results.

Watch the attached video, which shows (in the console log) the results I'm getting.

Here's the event handler:

function selectionChangeHandler(args) {
                console.log('In selectionChangeHandler - # objects selected = ' + diagram.model.selectedItems.children.length);
                var objectName = null;
                if (args.element.name) {
                    objectName = args.element.name;
                }
                if (objectName && objectName.substring(0, 9) != 'connector' && objectName.substring(0, 6) != 'bezier' && objectName.substring(0, 5) != 'Horiz' && objectName.substring(0, 8) != 'Vertical') {
                    var handles = diagram.model.selectedItems.userHandles;
                    handles[0].visible = true;
                    diagram.updateUserHandles(args.element);
                } else {
                    var handles = diagram.model.selectedItems.userHandles;
                    handles[0].visible = false;
                    diagram.updateUserHandles(args.element);
                }
                var node = args.element;
                if (node) {
                    if (node.addInfo) {
                        if (node.addInfo.NodeType) {
                            if (node.addInfo.NodeType == 'Task') {
                                document.getElementById('<%= lblRoleCount.ClientID %>').innerHTML = 0;
                                document.getElementById('<%= lblInputCount.ClientID %>').innerHTML = 0;
                                document.getElementById('<%= lblOutputCount.ClientID %>').innerHTML = 0;
                                document.getElementById('<%= lblDataCount.ClientID %>').innerHTML = 0;
                                document.getElementById('<%= lblToolCount.ClientID %>').innerHTML = 0;
                                document.getElementById('<%= lblProcCount.ClientID %>').innerHTML = 0;
                                document.getElementById('<%= lblNoteCount.ClientID %>').innerHTML = 0;

                                if (node.addInfo.roleCount) {
                                    document.getElementById('<%= lblRoleCount.ClientID %>').innerHTML = node.addInfo.roleCount;
                                }
                                if (node.addInfo.inputCount) {
                                    document.getElementById('<%= lblInputCount.ClientID %>').innerHTML = node.addInfo.inputCount;
                                }
                                if (node.addInfo.outputCount) {
                                    document.getElementById('<%= lblOutputCount.ClientID %>').innerHTML = node.addInfo.outputCount;
                                }
                                if (node.addInfo.dataCount) {
                                    document.getElementById('<%= lblDataCount.ClientID %>').innerHTML = node.addInfo.dataCount;
                                }
                                if (node.addInfo.toolCount) {
                                    document.getElementById('<%= lblToolCount.ClientID %>').innerHTML = node.addInfo.toolCount;
                                }
                                if (node.addInfo.procCount) {
                                    document.getElementById('<%= lblProcCount.ClientID %>').innerHTML = node.addInfo.procCount;
                                }
                                if (node.addInfo.noteCount) {
                                    document.getElementById('<%= lblNoteCount.ClientID %>').innerHTML = node.addInfo.noteCount;
                                }
                                var txtTaskName = $find('<%= txtTaskName.ClientID %>').set_value(node.labels[0].text);
                            }
                        }
                    }
                }
            }

I also have a change event on a textbox - you'll see evidence of that in the console log as well.  Please ignore.


Any idea what I am doing wrong?

What technique should I be using to determine the # of objects selected?

Thanks

Jim


Attachment: Syncfusion__Determining_Number_of_Objects_Selected__22Mar2015_f1a7c39c.zip

1 Reply

SG Shyam G Syncfusion Team March 23, 2015 11:29 AM UTC

Hi Jim

Thanks for using Syncfusion products.

We are able to reproduce the issue and we have confirmed this as bug and logged a report on this. Also we have created a support incident under your account to track the status of this issue.

Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let me know if you have any questions.

Regards,

Shyam G


Loader.
Live Chat Icon For mobile
Up arrow icon