Hi,
I am trying to display images in a tree using the HierarchicalDataSource.
My binding is currently defined as follows:
data =
new
kendo.data.HierarchicalDataSource({
transport: {
read: {
url:
"/Controller/Action"
,
dataType:
"json"
}
},
schema: {
model: {
id:
"Id"
,
hasChildren:
"HasChildren"
}
}
});
$(
"#tree"
).kendoTreeView({
dataSource: data,
dataTextField:
"Alias"
});
In my controller action I return a list of a class that contains an ImageUrl.
If i try and bind to the image in the following way, the source value of the rendered image tag equals "ImageUrl" and not the value defined in the object I am binding to.
schema: {
model: {
id:
"Id"
,
hasChildren:
"HasChildren"
,
imageUrl
"ImageUrl"
}
}
For example:
<
img
class
=
"k-image"
alt
=
""
src
=
"ImageUrl"
/>
However, I would expect that the src should equal whatever I have defined in the ImageUrl in the json object that I return, for example "Image.gif".
I have also tried using the sprite css class, however, I can not change the class either, it always takes the name that I have defined in the schema model.
I need to change the Image displayed for a tree node, depending on what I return during remote binding.
Can anybody assist me further? Or give me a few tips so I understand what is happening?
columns.Bound(p => p.Employee).ClientTemplate("#=Employee.EmployeeName#");
{"customerSatisfactionChart":[{"KPIColumnName":"Time To Reach Qualified Tech","KPIColumnValue":3.579831
},{"KPIColumnName":"Completeness Of Solution","KPIColumnValue":3.359243},{"KPIColumnName":"Opinion Of
Overall Service","KPIColumnValue":3.720588},{"KPIColumnName":"Tech Ability And Prod Knowledge","KPIColumnValue"
:3.636554},{"KPIColumnName":"Time To Provide Solution","KPIColumnValue":3.285714},{"KPIColumnName":"Ease
Of Requesting Help","KPIColumnValue":3.758403},{"KPIColumnName":"How Well Are You Kept Informed","KPIColumnValue"
:3.262605}]}
dataSource: { transport: { read: { url: '../Test/GetData', dataType: "json" } } }, schema: { data: "customerSatisfactionChart" }, series: [{ field: "KPITestColumnValue" }], categoryAxis: { field: "KPITestColumnName" },
a
|
[""KPIColumnName":"Time T...ColumnValue":"3.579831"",""KPIColumnName":"Comple...ColumnValue":"3.359243"",""KPIColumnName":"Opinio...ColumnValue":"3.720588"", 4 more...] |
var customerSatisfactionDataSource = new kendo.data.DataSource({ transport: { read: { url: '../Test/GetData', dataType: "json" } } });
function createkpiBreakdownChart(labelPosition) { $("#kpiBreakdownChart").kendoChart({ theme: $(document).data("kendoSkin") || "metro", dataSource: customerSatisfactionDataSource, schema: { a: "a" }, series: [{ field: "KPIColumnValue" }], categoryAxis: { field: "KPIColumnName" }, title: { text: "Customer Satisfaction" }, legend: { position: "bottom", visible: false, }, chartArea: { background: "#ffffff" }, seriesDefaults: { type: "bar" }, //series: [{ // name: "Performance Metrics", // data: [4.552162849872774, 4.391752577319588, 4.215633423180593, 4.345108695652174, 4.4728682170542635, 4.387005649717514, 4.351351351351352] //},], valueAxis: { minorUnit: .25, majorUnit: 1, min: 0, max: 5, plotBands: [{ from: 4, to: 5, color: '#000000', opacity: .1 }], labels: { labels: { format: "N0" }, }, tooltip: { visible: true, format: "N0" } }, //categoryAxis: { // categories: ['Ease of requesting help', 'Time to reach qualified technician', 'Time to provide a solution', 'Completeness of solution', 'Technical ability & product knowledge', 'How well we kept you informed', 'Overall opinion of service'], //}, tooltip: { visible: true, format: "#.##" } }); }
kendo.data.ObservableObject | kendo.data.Model The type depends on the schema.
var
model = kendo.data.Model.define({
id:
"ID"
,
fields: {
ID: { type:
"number"
, editable:
false
},
Name: { type:
"string"
, validation: { required:
true
} }
}
});
var
datasource = {
schema: {
model: model
}
};
var
ds =
new
kendo.data.DataSource(datasource);
ds.fetch(
function
() {
var
data = ds.at(0);
});