Solved

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

Posted on 2014-02-16
2
630 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
2 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS style formatting? 2 33
Send email using HTML and PHP in separate file 5 39
asp.net figure out error 3 23
what should i learn? javascript or typescript? 3 36
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
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…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

756 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