Hi Krishna,
Thanks for using Syncfusion product.
For your kind information, there is no support to connect to the SQL database in Javascript platform for rendering TreeGrid. So we have prepared a sample in ASP.Net MVC to achieve the database connectivity. We have retrieved and updated the TreeGrid datasource with the help of “EndEdit” and “ActionComplete” client side events. Please refer the below code snippet to achieve this.
@(Html.EJ().TreeGrid("TreeGridContainer"). //… ClientSideEvents(eve=>{ eve.EndEdit("endEdit"); eve.ActionComplete("ActionComplete"); }). )
@(Html.EJ().ScriptManager()) <script type="text/javascript">
function endEdit(args) { var editedRecord = args.data.item; //This varible holds the data of the edited record. You can updated it to your remote datasource $.ajax({ type: "POST", url: "/TreeGrid/Delete", //Delete is Server side method data: editedRecord, dataType: "json" }); }
function ActionComplete(args) { var record = args.data; if (args.requestType === 'addNewRow') { //Newly Added Record is obtained here , which can be updated to database addedRecord = args.addedRow; $.ajax({ type: "POST", url: "/TreeGrid/Add",//Add is Server side method data: addedRecord, dataType: "json" });
} else if (args.requestType === 'delete') { var data = args.data; var deletedRecord = data.item; //This is the deleted item. $.ajax({ type: "POST", url: "/TreeGrid/Delete", //Delete is Server side method data: deletedRecord, dataType: "json" });
//If deleted item has child records, we need to delete that too
if (data.hasChildRecords) { deleteChildRecords(data); } }
// To update the database during editing and update operation else if (args.requestType === 'recordUpdate') { var item = args.data.item; $.ajax({ type: "POST", url: "/Gantt/Update", //Update is Server side method data: item, dataType: "json" }); } }
//Delete inner level child records function deleteChildRecords(record) { var childRecords = record.childRecords, length = childRecords.length, count, currentRecord; for (count = 0; count < length; count++) { currentRecord = childRecords[count]; var deletedChildRecord = currentRecord.item; //This is the deleted child item. //If the above deleted child record has child records, then we need to delete that too. if (currentRecord.hasChildRecords) { deleteChildRecords(currentRecord); } } } </script> |
As of now we have prepared a sample with MS SQL Server database. But events are the same to update a SQL database in TreeGrid . Please find the sample in the below location.
Sample: http://www.syncfusion.com/downloads/support/forum/119689/ze/Simpledatabase-1129834942
Please get back to us if you need the TreeGrid sample using MY SQL database .
Please let us know if you need further assistance on this.
Regards,
Mahalakshmi K.
Hi Krishna,
Sorry about the inconvenience caused.
Currently there is no support for event handlers to sub-context menu item in TreeGrid control. We have already logged feature report regarding this. A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Please let us know if you require further assistance on this.
Regards,
Mahalakshmi K.
Hi Krishna,
Thanks for the update.
We will let you know once the feature has got implemented.
Please let us know if you need further assistance on this.
Regards,
Mahalakshmi K.