Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
nodeContentTemplate invoking Knockout viewmodel methods
posted

Hi All,

I am using nodeContentTemplate for rending nodes. I have a situation where I have to control the image display using Knockout properties or methods, for that I tried below code but is not working . does invoking knockout function is support from codecontroltemplate? If yes can you please share the details. If Knockout is not supported what are ways to control the image rending using global variable??

if I use the same method in tree events like nodeCheckstateChanged,nodeCheckstateChanging & nodeExpanding...etc  , it is working fine.

ko.bindingHandlers.edmTreeData = {

init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {

},
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var edmData = valueAccessor();
var vm = bindingContext.$root;
$(element).igTree({
height: 310,
dataSource: $.extend(true, [], edmData),
singleBranchExpand: true,
dataSourceType: 'json',
checkboxMode: 'triState',
initialExpandDepth: -1,
pathSeparator: '.',
bindings: {
textKey: 'Text',
valueKey: 'Value',
imageUrlKey: "ImageUrl",
childDataProperty: 'Folder',
nodeContentTemplate: "${Text} {{if ${Hierarchy} == 'field'}} data-bind='click: vm.AddEDMTreeNode(this)' src='http://png.findicons.com/files/icons/1156/fugue/16/plus.png' /> {{elseif ${Hierarchy} == 'Newplatforminfo'}} {{/if}}"
},

});
}
};