简体   繁体   English

使用javascript动态创建的kendo UI网格

[英]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: 我有一个名为“操作链接”的网格列,它以JSON格式显示数据,如下所示:

  {"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. 我能够解析数据并获取所有标志和ID,但现在的问题是,如果我看到"Flag1" = 1那么在同一列“动作链接”中,我需要替换数据以显示图像图标并打开“ onclick ”参数为Id = 1的新窗口。

If all the flags are 1 then show 3 different icons and onclick open a new window with respective parameter id. 如果所有标志均为1,则显示3个不同的图标,然后onclick打开带有相应参数ID的新窗口。 I am doing it on client side as the fields are created on fly using kendo UI and javascript. 我正在客户端执行此操作,因为使用kendo UI和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 Kendo Grid使用template功能有条件地在aa列中显示内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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