I am trying to append two columns bound into one kendo grid column. Below doesn't seem to work.
var grid = $("#grid").kendoGrid({
dataSource: { data: SomeData },
columns: [{
field: "Column1" + "Column2"
}]
}).data("kendoGrid");
If you do not need to edit the cell you can do what is known as composed cells or composition and it is implemented using KendoUI template
. (Try googling for "kendoui grid with composed cells").
Example
var leitmotifs = [
{
company: "OnaBai",
leitmotif: "Working on a cloud of documents!"
},
{
company: "Nike",
leitmotif: "Just do it!"
}
];
var grid = $("#table").kendoGrid({
dataSource: {
data: leitmotifs
},
columns : [
{
title: "Company",
template: "#= company + ' : ' + leitmotif #"
}
]
});
Did you have a look at the schema.parse method on the DataSource? You can add up columns there as new fields with no issues. Then the field would be available when you get to the grid.
dataSource: {
transport: {
read: "things"
},
schema: {
parse: function (data) {
// return a new collection which has a new field
// that adds fields 2 and 3 together
return $.map(data, function(item) {
item.field4 = item.field2 + item.field3;
return item;
});
}
}
}
Here is an example...
http://jsbin.com/azizaz/1/edit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With