[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to edit hierarchy to add new child values using JSON files

Posted on 2014-02-16
2
Medium Priority
?
643 Views
Last Modified: 2014-02-18
I have two JSON files, Parent and Child.

How do I databind these for hierarchical editing using Knockout.JS / XEditable
in a HTML5 page.

eg edit Child and Add related records

Please provide samples and Code if possible
Thankyou
T1-Parent.JSON.txt
T2-Child.JSON.txt
0
Comment
Question by:XGIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 39865950
You can do this with pure JavaScript.

http://jsbin.com/bohug/1/edit

Why the need for knockout? Is the data tired to the ui ? ?

var mychildren = [{'CID':'1','CIDName':'Parent 1','PID':'1'},{'CID':'2','CIDName':'Parent 2','PID':'2'},{'CID':'3','CIDName':'Parent 3','PID':'3'},{'CID':'4','CIDName':'Parent 1','PID':'1'},{'CID':'5','CIDName':'Parent 1','PID':'1'},{'CID':'6','CIDName':'Parent 2','PID':'2'},{'CID':'7','CIDName':'Parent 3','PID':'3'}];
var myparents = [{'PID':'1','PIDName':'Parent 1'},{'PID':'2','PIDName':'Parent 2'},{'PID':'3','PIDName':'Parent 3'}];

for (var chd in mychildren) {
    for (var prt in myparents) {
        if (mychildren[chd].PID == myparents[prt].PID) {
            mychildren[chd].parent = myparents[prt];
        }
    }
}

console.log(mychildren);

Open in new window

0
 
LVL 7

Author Closing Comment

by:XGIS
ID: 39869441
Hello Rob.... thankyou for that clarification.... no it would be me that is 'tired'...  for not realising it...  and I am also  re'tiring' conventional sql but it is definitely not tied to the page, only to the controls it is servicing at the time and most likely provided in a JSON file that is being appended with child records and synchronised between users during a session.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question