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

Event binding

Hi,

I'm new to Syncfusion libs, and got very confused with docu and components design.

Any way...
trying to bind to ejTreeView events for e.g.
 as per documentation I tried to do like:

function checkCallback() {
                    console.log('check', arguments);
                }

var myTree = $('#treeDiv').ejTreeView({
                    fields: { id: "id", parentId: "pid", text: "name", hasChild: "hasChild", dataSource: outlookicons, expanded: "expanded" },
                    allowEditing: true,
                    allowDragAndDrop: true,
                    check: 'checkCallback' // <- NEVER fired - strange way of binding callbacks
                });

Does Syncfusion components support standard way of binding to the events?

myTree.on('check', function(){}); 
myTree.un('check', function(){}); 
myTree.on('dropped', function(){}); 
myTree.on('beforedrop', function(){}); 
etc.
Any help appreciated.

Andrzej



2 Replies

AS Andrzej Siedy November 26, 2014 02:48 PM UTC

Ok, got that
$('#treeDiv').ejTreeView('model.nodeCheck', function(){ });


HP Harikrishnan P Syncfusion Team November 28, 2014 04:08 AM UTC

Hi Andrzej,

Thanks for using Syncfusion products.

Query: check: 'checkCallback' // <- NEVER fired - strange way of binding callbacks

We would like to let you know that, there is no event in Treeview component as “check”. In the above code instead of specifying the event name as “nodeCheck” it is used as “check”. Please change it to “nodeCheck” and the event will fire properly.

We can also bind the events attach its callback function, on the event declaration itself. Please refer the below code

 

[Script]

 

//callback function attached on the event declaration itself

                var myTree = $('#treeDiv').ejTreeView({

                    fields: { id: "id", parentId: "pid", text: "name", hasChild: "hasChild", dataSource: outlookicons, expanded: "expanded" },

                    allowEditing: true,

                    allowDragAndDrop: true,

                    nodeCheck: function (args) {

                        alert("Check event trigerred");

                    }

                });

 

 

Query: Does Syncfusion components support standard way of binding to the events?

Yes, Syncfusion components support standard structure for binding the events as like binding the jQuery events. Please refer the below code,

          

[Script]

 

//standard structure for binding events as like binding jQuery events

//while using this structure, the event name has to be specified in the format "pluginname" + "corresponding event name"

//Here in "ejTreeViewnodeCheck" ejTreeView is the plugin name and nodeCheck is the event name

            $("#treeView").on('ejTreeViewnodeCheck', function () {

                alert("Checkbox Checked");

            });

 

 

For your convenience, we have attached a sample in the following location to exhibit the above behavior. Please download the sample from the following location

Sample Location : Treeview Sample

Please let us know if you have further queries

Regards,

HariKrishnan


Loader.
Live Chat Icon For mobile
Up arrow icon