kendo UI grid created on fly using javascript

两盒软妹~` 提交于 2021-01-28 08:49:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!