简体   繁体   中英

kendo UI grid created on fly using javascript

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.

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 aa column

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM