问题
I have one of the grid column called Action Links and it shows data as JSON format as follows:
{"Id" : "1", "Flag1": "1", "Flag2": "1"}
{"Id" : "2", "Flag1": "1", "Flag2": "1", "Flag3": "1"}
{"Id" : "3", "Flag1": "1" }
I am able to parse data and get all the Flags and Id's but my problem now is if i see "Flag1" = 1
then in the same column Action Links,i need to replace the data to show a image icon and "onclick
" open a new window with parameter as Id = 1.
If all the flags are 1 then show 3 different icons and onclick open a new window with respective parameter id. I am doing it on client side as the fields are created on fly using kendo UI and javascript.
Can anyone please help.
回答1:
If I understood correctly you want your kendo grid to have a conditional display on a particular column; if so on your grid declaration:
... , {
field: "Flag1",
title: "Flag",
template: function (dataItem) {
var value = dataItem. Flag1;
if (!value || value === 1) {
return 'image/html here';
}
return "something else";
},
}, { ..
Kendo Grid uses template
function to conditionally display content in a a column
来源:https://stackoverflow.com/questions/33048776/kendo-ui-grid-created-on-fly-using-javascript