A remote hierarchical data source delivers JSON that looks like the following: Note the .data property which contains additional information.
The template in the .kendoTreeView constructor is thus and will display additional status information when the treeview is rendering a 'level 3' node:
My problem is that when a some property .data changes, the tree node is not redrawn.
User does some activity runs a getJSON that returns an updated status for an id.
What would need to be done to have the treeview observe the 'additional information' in dsData.data (or dsData.data itself) and rerender when something gets set ?
I would prefer to _not_ have to do something like this (untested):
dsData.set('data.status', info.result.status);
dsData.set('text', dsData.text');
Thanks,
Richard
jQuery182041788989288830735_1364362919255([
{
"id"
:
"6a488457-5b85-48fc-be24-b469219564c4"
,
"sprite"
:
"custom3"
,
"text"
:
"Silk"
,
"hasChildren"
:
true
,
"data"
:{
"nodetype"
:
"Fabric"
,
"level"
:3
,
"activity"
:0
,
"maintenance"
:NaN
,
"status"
:3
}
}
,
{
"id"
:
"8a9e479a-4448-462e-9151-b1913cc1660e"
,
"sprite"
:
"custom3"
,
"text"
:
"Wool"
,
"hasChildren"
:
true
,
"data"
:{
"nodetype"
:
"Fabric"
,
"level"
:3
,
"activity"
:0
,
"maintenance"
:NaN
,
"status"
:3
}
}
,
{
"id"
:
"da373cd1-4264-4096-9955-5527e6c49dd9"
,
"sprite"
:
"custom3"
,
"text"
:
"Canvas"
,
"hasChildren"
:
true
,
"data"
:{
"nodetype"
:
"Fabric"
,
"level"
:3
,
"activity"
:0
,
"maintenance"
:NaN
,
"status"
:4
}
}
])
The template in the .kendoTreeView constructor is thus and will display additional status information when the treeview is rendering a 'level 3' node:
window.reportUrl =
'/reporter'
;
window.statusCode = [
'bla'
,
'bla'
,
'bla'
];
template:
"<span class='name'>#: item.text #</span>"
+
"# if (item.data.level == 3) {#"
+
"# if (item.hasChildren) {#"
+
" | <a href='#= window.reportURL #?id=#= item.id #' title='View Report' target='_blank'>"
+
"<img alt='View Report' class='cm-icon' src='/images/report.png'>"
+
"</a>"
+
"#}#"
+
"# if (('status' in item.data) && !isNaN(item.data.status)) {#"
+
" | <span class='cs-status'>Status: #= window.statusCode[item.data.status] #</span>"
+
"#}#"
+
"#}#"
User does some activity runs a getJSON that returns an updated status for an id.
$.getJSON ( .... )
.done (
function
(info) {
// info looks like {result:{id:<some-id>,status:<some-status>}}
var
tv = $(
'#treeview'
).data(
'kendoTreeView'
);
var
dsData = tv.dataSource.get(info.result.id);
dsData.data.set(
'status'
, info.result.status);
// does not cause node to be redrawn
dsData.set(
'data.status'
, info.result.status);
// does not cause node to be redrawn
dsData.set(
'text'
,
'BLA BLA BLA'
);
// DOES cause node to be redrawn
});
I would prefer to _not_ have to do something like this (untested):
dsData.set('data.status', info.result.status);
dsData.set('text', dsData.text');
Thanks,
Richard