0

How to create tree view structure by fetching data from sql?

HI All, I am trying to create the tree view by fetching data from sql db.please need help to solve this. the code i have tried is *************************** I am trying to build a tree structure by fetching data from mysql database. <!DOCTYPE html> <html> <head> <title>Media chain</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css" /> <script type="text/javascript" charset="utf8" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"></script> <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js"></script> </head> <body> <div class="container"> <div class="panel panel-default"> <div class="panel-heading"> <h1>Media chain</h1> </div> <div class="panel-body"> <div class="col-md-8" id="treeview_json"> </div> </div> </div> </div> <script type="text/javascript"> $(document).ready(function(){ // var parentKey='0'; var subdata=[];var data; $.ajax({ type: "GET", url: "/mediaChain", dataType: "json", success: function(response) { $.each(response, function(i, item) { var child=item["Child"]; subdata["Licensor"]=item["Licensor"]; subdata["Parent"]=item["Parent"]; subdata["Child"]=item["Child"]; subdata.push(item); }); var output=[]; $.each( subdata, function( key, value ) {

10th Jun 2019, 5:22 AM
Bhavani Sankar
Bhavani Sankar - avatar
4 ответов
+ 2
Please save your code and attach the link on your question Description instead. Pasting code directly in there doesn't help, especially if the code is quite long (it will be truncated from character limits). Remove all codes and just attach the link. Read below post on how to share links. https://www.sololearn.com/post/74857/?ref=app May you find a solution 👍
10th Jun 2019, 7:17 AM
Ipang
+ 1
Hi Ipang , Thank u for reply . But the above mentioned link is not working. please help
10th Jun 2019, 7:27 AM
Bhavani Sankar
Bhavani Sankar - avatar
+ 1
Hello Bhavani, sorry for delay, I was out of battery : ) That link can only be viewed by using SoloLearn mobile app, I think you use SoloLearn website, that's why you can't open it. Do you know how to create and save code in Playground? I see you don't have any public code at the moment. So just go to Code Playground https://www.sololearn.com/Codes/ Select New Code, paste the code in code editor then save the code. Once you have saved the code you can copy the code URL from browser's address bar, this is the link you need to attach in your original question Description. Next go back to this thread, and edit the question. Remove all code snippets from Description, and paste the link to replace it with, and you're good to go. I'd also recommend to remove the partial code you wrote in answers section, now that you have a working link people can use to access your code. Good luck! 👍
10th Jun 2019, 9:11 AM
Ipang
0
{S.No: 1, Licensor: "imaginationstudio", Parent: "imaginationstudio", Child: "Cineworld", Region: "UK",…} Child: "Cineworld" Licensor: "imaginationstudio" Parent: "imaginationstudio" Region: "UK" S.No: 1 1: {S.No: 2, Licensor: "Cineworld", Parent: "Cineworld", Child: "TVOIO", Region: "UK",…} Child: "TVOIO" Licensor: "Cineworld" Parent: "Cineworld" Region: "UK" S.No: 2 2: {S.No: 3, Licensor: "TVOIO", Parent: "TVOIO", Child: "YUI", Region: "UK",…} Child: "YUI" Licensor: "TVOIO" Parent: "TVOIO" Region: "UK" S.No: 3 -----My output ---- looks like this--------
10th Jun 2019, 5:23 AM
Bhavani Sankar
Bhavani Sankar - avatar