I have some complex question. My first JSON url has this properties, ID, Name and Parameter. Then when I call the JSON, I want to go to retrieve another JSON URL based on the ID to get the child ID.
Then I want to output as Child ID, Parent Name and Parent Parameter.
I've gotten to load the second JSON to a model, but I'm confused on how to output them
Here is the code
$.getJSON(url, function (data) {
var MasterViewModel = {
model: ko.mapping.fromJS(data),
modelchoprocess: ko.mapping.fromJS([data][0]["TM1.ChoreProcessRel"])
};
MasterViewModel.itemById = function(arr, Parameters) {
return ko.utils.arrayFirst(arr, function(item){
var chourl = webapiurl+'/Models'+getUrlVars()["model"]+'/ChoreProcess('+item.ID()+')?$expand=Process';
$.ajax({
url: chourl,
type: "GET",
dataType: 'json',
success: function(dataret) {
MasterViewModel.cho = {
choID: ko.mapping.fromJS([data][0]["TM1.ChoreProcessRel"]["ID"]),
choName: ko.mapping.fromJS([data][0]["TM1.ChoreProcessRel"]["Name"]),
choParam: Parameters
};
console.log(MasterViewModel.cho);
}
});
});
};
MasterViewModel.series = ko.utils.arrayMap(MasterViewModel.modelchoprocess(), function(cub){
var cubdim = MasterViewModel.itemById(MasterViewModel.modelchoprocess(), cub.ParemeterValues());
return {
ParemeterValues: cub.ParemeterValues,
Name: cub.Name,
ID: cub.ID
};
});
ko.applyBindings(MasterViewModel);
And here I call the html
<tbody data-bind="foreach: series">
<tr>
<td><a data-bind="attr: { href: './processsingle.html?model=='+getTopUrlVars()['model']+'&api==Process('+$data.ID()+')' }, text: $data.Name"></a></td>
<td data-bind="text: $data.ParemeterValues"></td>
</tr>
</tbody>
And here is the model url 1
[
{
"ParemeterValues": "Actual,2011,SYS.LoadCompanies,y,y",
"ID": "1771cdf7-7a73-49e4-8538-0d0cad965226",
"Name": "EXEC.Data.PLandBS.FromFMISMultipleCompanies",
},
{
"ParemeterValues": "Actual,2012",
"ID": "19439ce4-240c-4f2a-98ee-47cb1708b339",
"Name": "Data.BS.BringForwardOpeningBalances",
}
]
and the model url2
{
"ID": "1771cdf7-7a73-49e4-8538-0d0cad965226",
"Name": "EXEC.Data.PLandBS.FromFMISMultipleCompanies",
"TM1.ChoreProcessesProcess":
[
{
"Name": "EXEC.Data.PLandBS.FromFMISMultipleCompanies",
"ID": "dd1acc0b-51ff-4844-b6c4-c67640b326c4",
}
]
}
Aucun commentaire:
Enregistrer un commentaire