I want to create knockout computed function which will do ajax call with breeze method and retrieve all records based upon entity type as shown below.
standardResourceProperty.listItems = ko.computed({
read: function () {
listObsevable = ko.observableArray();
datacontext.getStandardResourcePropertyListItems(standardResourceProperty.id(),listObsevable);
return listObsevable;
},
write: function (value) {
}
});
The function is written inside standardResourcePropertyInitializer which is initialized with
metadataStore.registerEntityTypeCtor(
'StandardResourceProperty', function () { this.isPartial = false; }, standardResourcePropertyInitializer);
I want to have list when i iterate standard resource in ui with knockout for each .
However, i am getting datacontext as undefined . Even thought it is registered properly with durandal in the same file as
define(['config', 'durandal/system', 'services/logger', 'services/datacontext'],
function (config, system, logger,datacontext) {
My data context code looks like below
define([
'durandal/system',
'services/model',
'config',
'services/logger',
'services/breeze.partial-entities'],
function (system, model, config, logger, partialMapper) {
var datacontext = {
getResources: getResources,
cancelChanges: cancelChanges,
saveChanges: saveChanges,
getStandardResourceProperty: getStandardResourceProperty,
getStandardResourcePropertyListItems: getStandardResourcePropertyListItems,
getResourceProperty: getResourceProperty,
createResource: createResource,
};
return datacontext;
});
Please let me know for any suggestion.
After doing some more investigation i have implemented server side query to return related objects(child objects ) and then created computed for accessing it with knockout binding in view.