Hi,
I have the grid and the model below. Everything works but getSum, I get a "getSum is not defined" error. Any idea?
<div class="k-widget"
data-role="grid"
data-bind="source: nbh"
data-columns="[{title: 'Tâche', field: 'task'}, {title: 'Heures', field: 'hours', width: '125px', format: '{0} h', aggregates: ['sum'],
footerTemplate: 'Total: #= data.hours? data.hours.sum: 0 # h'}, {title: 'Personnelle', field: 'personal', hidden: true,
groupHeaderTemplate: '#= value? \'Projets\':\'Tâches personnelles\'# (#= getSum(value) # h)'}]">
</div>
bound to this model:
var model = kendo.observable({
nbh: new kendo.data.DataSource({
aggregate: [{ field: "hours", aggregate: "sum" }]
}),
getSum: function (value) {
var datasource = this.nbh;
var result;
//loops through the dataSource view
$(datasource.view()).each(function (index, element) {
//compares view value with the current template value
if (element.value === value) {
result = element.aggregates.hours.sum; //gets the aggregate value
}
});
return result;
}
});
Thanks,
Alexis
I have the grid and the model below. Everything works but getSum, I get a "getSum is not defined" error. Any idea?
<div class="k-widget"
data-role="grid"
data-bind="source: nbh"
data-columns="[{title: 'Tâche', field: 'task'}, {title: 'Heures', field: 'hours', width: '125px', format: '{0} h', aggregates: ['sum'],
footerTemplate: 'Total: #= data.hours? data.hours.sum: 0 # h'}, {title: 'Personnelle', field: 'personal', hidden: true,
groupHeaderTemplate: '#= value? \'Projets\':\'Tâches personnelles\'# (#= getSum(value) # h)'}]">
</div>
bound to this model:
var model = kendo.observable({
nbh: new kendo.data.DataSource({
aggregate: [{ field: "hours", aggregate: "sum" }]
}),
getSum: function (value) {
var datasource = this.nbh;
var result;
//loops through the dataSource view
$(datasource.view()).each(function (index, element) {
//compares view value with the current template value
if (element.value === value) {
result = element.aggregates.hours.sum; //gets the aggregate value
}
});
return result;
}
});
Thanks,
Alexis