I would like to see a complete example of treegrid in javascript with connections to "mysql" bd which have fuciones crud
Hi good day
I would like to see a complete example of treegrid in javascript with connections to "mysql" bd which have fuciones crud
thank you very much
I perform this request because I can not find good documentation on this control
SIGN IN To post a reply.
6 Replies
JS
Jonesherine Stephen
Syncfusion Team
September 12, 2016 09:31 AM UTC
Hi Andres,
Thanks for contacting Syncfusion support
Query 1 I would like to see a complete example of treegrid in javascript with connections to "mysql" db which have functions crud
Solution: We have prepared the workaround and rendered the TreeGrid with mySql database.
And by using the “actionComplete” and “endEdit” client side events in TreeGrid we can update the data base during insert, update and delete action.
Please find the code example below:
|
[aspx]
<script type="text/javascript">
$(function () {
var dataManager = ej.DataManager({
url: "/TreeGrid.aspx/GetTreeGridData",
adaptor: "UrlAdaptor"
});
$("#treeGrid").ejTreeGrid({
dataSource: dataManager,
endEdit: function (args) {
//To update after editing TreeGrid
var editedRecord = args.data.item;
PageMethods.UpdateIt(editedRecord);
},
actionComplete: function ActionComplete(args) {
if (args.requestType === 'addNewRow') {
//Newly Added Record is obtained here , which can be updated to database
addedRecord = args.addedRow;
PageMethods.AddIt(addedRecord);
}
else if (args.requestType === 'delete') {
var data = args.data;
var deletedRecord = data.item; //This is the deleted item.
PageMethods.DeleteIt(deletedRecord);
//If deleted item has child records, we need to delete that too
if (data.hasChildRecords) {
deleteChildRecords(data);
}
}
}
});
});
//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.
PageMethods.DeleteIt(deletedChildRecord);
//If the above deleted child record has child records, then we need to delete that too.
if (currentRecord.hasChildRecords) {
deleteChildRecords(currentRecord);
}
}
} |
Please find the code example below for sever side methods to render the TreeGrid with mySql database
|
[aspx.cs]
//we need to pass the servername,database name, username and password to connect the mySql server
string con_string = "Server=localhost;Database=tgrid;Uid=root;Pwd=Treegrid";
[WebMethod]
public void Update(TaskData Task)
{
MySqlConnection con;
MySqlCommand command;
con = new MySqlConnection(con_string);
command = con.CreateCommand();
command.CommandText = "UPDATE gantt SET taskName='" + Task.Name + "', startDate='" + Task.StartDate + "', duration='" + Task.Duration + "' WHERE taskID='" + Task.Id + "'";
con.Open();
command.ExecuteNonQuery();
con.Close();
}
public void Add(TaskData Task)
{
MySqlConnection con;
MySqlCommand command;
con = new MySqlConnection(con_string);
command = con.CreateCommand();
command.CommandText = "INSERT INTO gantt SET taskID='" + Task.Id + "', taskName='" + Task.Name + "', startDate='" + Task.StartDate + "',duration='" + Task.Duration + "',parentID='"+Task.ParentId + "'";
con.Open();
command.ExecuteNonQuery();
con.Close();
}
public void Delete(TaskData Task)
{
MySqlConnection con;
MySqlCommand command;
con = new MySqlConnection(con_string);
command = con.CreateCommand();
command.CommandText = "DELETE FROM gantt WHERE taskID='" + Task.Id + "'";
con.Open();
command.ExecuteNonQuery();
con.Close();
} |
We have also prepared the sample to render the TreeGrid using mySql database with ASP as the code behind. Please find the sample from below location:
Please find our Knowledge base to render the TreeGrid with MySql Database using PHP.
Disclaimer: Please refer the MySql.Data.dll to render the TreeGrid with mysql data base.
Query2: I perform this request because I cannot find good documentation on this control
Solution:
We are currently enhancing our online documentation. It will available at the end of October 2016.
Please let us know if you require further assistance on this.
Regards,
Jone sherine P S
Regards,
Jone sherine P S
Hi Andres,Thanks for contacting Syncfusion supportQuery 1 I would like to see a complete example of treegrid in javascript with connections to "mysql" db which have functions crudSolution: We have prepared the workaround and rendered the TreeGrid with mySql database.And by using the “actionComplete” and “endEdit” client side events in TreeGrid we can update the data base during insert, update and delete action.Please find the code example below:
[aspx]<script type="text/javascript">$(function () {var dataManager = ej.DataManager({url: "/TreeGrid.aspx/GetTreeGridData",adaptor: "UrlAdaptor"});$("#treeGrid").ejTreeGrid({dataSource: dataManager,endEdit: function (args) {//To update after editing TreeGridvar editedRecord = args.data.item;PageMethods.UpdateIt(editedRecord);},actionComplete: function ActionComplete(args) {if (args.requestType === 'addNewRow') {//Newly Added Record is obtained here , which can be updated to databaseaddedRecord = args.addedRow;PageMethods.AddIt(addedRecord);}else if (args.requestType === 'delete') {var data = args.data;var deletedRecord = data.item; //This is the deleted item.PageMethods.DeleteIt(deletedRecord);//If deleted item has child records, we need to delete that tooif (data.hasChildRecords) {deleteChildRecords(data);}}}});});//Delete inner level child recordsfunction 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.PageMethods.DeleteIt(deletedChildRecord);//If the above deleted child record has child records, then we need to delete that too.if (currentRecord.hasChildRecords) {deleteChildRecords(currentRecord);}}}Please find the code example below for sever side methods to render the TreeGrid with mySql database
[aspx.cs]//we need to pass the servername,database name, username and password to connect the mySql serverstring con_string = "Server=localhost;Database=tgrid;Uid=root;Pwd=Treegrid";[WebMethod]public void Update(TaskData Task){MySqlConnection con;MySqlCommand command;con = new MySqlConnection(con_string);command = con.CreateCommand();command.CommandText = "UPDATE gantt SET taskName='" + Task.Name + "', startDate='" + Task.StartDate + "', duration='" + Task.Duration + "' WHERE taskID='" + Task.Id + "'";con.Open();command.ExecuteNonQuery();con.Close();}public void Add(TaskData Task){MySqlConnection con;MySqlCommand command;con = new MySqlConnection(con_string);command = con.CreateCommand();command.CommandText = "INSERT INTO gantt SET taskID='" + Task.Id + "', taskName='" + Task.Name + "', startDate='" + Task.StartDate + "',duration='" + Task.Duration + "',parentID='"+Task.ParentId + "'";con.Open();command.ExecuteNonQuery();con.Close();}public void Delete(TaskData Task){MySqlConnection con;MySqlCommand command;con = new MySqlConnection(con_string);command = con.CreateCommand();command.CommandText = "DELETE FROM gantt WHERE taskID='" + Task.Id + "'";con.Open();command.ExecuteNonQuery();con.Close();}We have also prepared the sample to render the TreeGrid using mySql database with ASP as the code behind. Please find the sample from below location:Please find our Knowledge base to render the TreeGrid with MySql Database using PHP.Disclaimer: Please refer the MySql.Data.dll to render the TreeGrid with mysql data base.Query2: I perform this request because I cannot find good documentation on this controlSolution:We are currently enhancing our online documentation. It will available at the end of October 2016.Please let us know if you require further assistance on this.
Regards,
Jone sherine P S
I'm Giando based on the example of the link
https://www.syncfusion.com/kb/7038/how-to-perform-crud-operation-in-treegrid-using-php I can delete, create a new record and update perfectly
but I have the following problems:
- To create a new row does not show me the "taskid" (autoincrement) and if I press the esc key to exit, I delete the row
- When I drag a row to acerla daughter of another, delete my record
JS
Jonesherine Stephen
Syncfusion Team
September 13, 2016 11:00 AM UTC
Hi Andres,
Please find the response below:
|
Query |
Response | |
|
To create a new row does not show me the "taskid" (autoincrement) |
At present there is no support to auto increment the taskId while we adding a new record. For this we have already logged a feature request regarding this. It will be implemented in any of our upcoming main release. | |
|
if I press the esc key to exit, I delete the row |
1. As per the current behavior, if we press the “esc” key before saving the newly added record then it deletes the newly added record.
2. While rendering the TreeGrid with mySql database the taskId should be unique.
3. If incase another record having the taskId similar to the newly added record’s taskId that record will also be deleted along with newly added record after pressing “esc” key. | |
|
When I drag a row to acerla daughter of another, delete my record |
We have prepared the work around and updated the mySql database during drag and drop action using “rowDrag” and “rowDragStop” client side events.
Please find the code example below:
We have also prepared the sample for your reference. Please find the sample from the below location.
|
Regards,
Jone sherine P S
AP
andres patiño
September 14, 2016 09:50 PM UTC
the example can be with mysql and php thanks
JS
Jonesherine Stephen
Syncfusion Team
September 15, 2016 11:18 AM UTC
Hi Williams,
We have prepared the work around and rendered the TreeGrid sample with “mySql” database using PHP.
And also performed the CRUD operations by using the TreeGrid client side events “endEdit” “actionComplete”,”rowDragStop”
and using ajax post we have updated the data base in server side
Please find the code example below
|
Server side |
Client side | ||
|
DataBinding:
|
| ||
|
Update:
|
| ||
|
Add:
|
| ||
|
Delete:
|
|
We have also prepared the sample for your reference .Please find the sample from below location:
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/phpsample-treegrid1744410994
Please let us know if you require further assistance on this,
Thanks,
Jone sherine P S
JS
Jonesherine Stephen
Syncfusion Team
September 15, 2016 11:53 AM UTC
Hi Andres,
Please ignore the previous update.
We have prepared the work around and rendered the TreeGrid sample with “mySql” database using PHP. And also performed the CRUD operations by using the TreeGrid client side events “endEdit” “actionComplete”,”rowDragStop” and using ajax post we have updated the data base in server side
Please find the code example below
|
Server side |
Client side | ||
|
DataBinding:
|
| ||
|
Update:
|
| ||
|
Add:
|
| ||
|
Delete:
|
|
We have also prepared the sample for your reference .Please find the sample from below location:
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/phpsample-treegrid1744410994
Please let us know if you require further assistance on this,
Thanks,
Jone sherine P S
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
AP andres patiño
- Sep 9, 2016 04:06 PM UTC
- Sep 15, 2016 11:53 AM UTC