0

我有一个数据表,aaData其中描述了用户创建的任务。现在,数据表中有一个action列,其中有两个或三个操作按钮或徽标,如 pdf - 查看该任务的用户指南,浏览 - 任务源代码的链接,一个是贡献者徽标,onclick 应显示贡献者对于该特定任务。

aaData是填充表格的以下格式

"aaData": [
    [
        "JSAG Home Page",
        "JSAG Home page contains information about various POCs done",
        "05/12/2012",
        [
                {
                   "displayValue":"Browse",
                   "link":"http://myTask.com/home",
                   "displayIcon" : "browselogo"
                },
                {   
                    "displayValue":"Source Code",
                    "link":"svn/HomePage/trunk/",
                    "displayIcon" : "svnlogo"
                },
                {   
                   "displayValue":"Audience Overview",
                    "link":"svn/Documents/Audience Overview.pdf",
                    "displayIcon" : "pdflogo"
               },
                 {  
                    "displayValue":"Contributors: ABC,XYZ",
                    "link":"#",
                    "displayIcon" : "people"
             }

        ],

    ],
    [
        "Backlog",
        "Backlog Forum application is designed to provide a platform for different groups to maintain backlog task items. ",
        "25/08/2012",
        [
            {   
                "displayValue":"Browse",
                "link":"http://mytask.com/BacklogApp",
                "displayIcon" : "browselogo"
            },
            {   
            "displayValue":"Source Code",
                "link":"svn/trunk/webapp-project/",
                "displayIcon" : "svnlogo"
            },
            {   
            "displayValue":"Contributors: ABC",
                "link":"#",
                "displayIcon" : "people"
            }
        ],

    ]
  ]

这种格式适用于所有数据表,并且所有贡献者徽标都在那里。我想要的是,当用户单击贡献者图标时,他应该能够看到那些贡献者"ABC, XYZ, PQR"

我想获取操作列数据,然后$each()获取contributors数组,但我无法继续进行。

我怎样才能做到这一点?我如何获取列值onclick,因为每个数据表都是动态填充的。请帮忙。

下面是填充贡献者 div 的代码

$(document).on('click', '#contributor', function(contributors){
        $.each(contributors, function(i, data) {
            var ul_data = "<li><h3>"+ data+ "</h3></li>";
            $("#contributors_div").append(ul_data);
        });
   }
    $('#contributors_div').show();
   });

我如何获得recentActdata我的贡献者 JSON 数组

4

1 回答 1

1

它将与此类似,前提是您在变量 oTable 中声明数据表

$(document).on('click', '#contributor', function(){
      var aPos = oTable.fnGetPosition( $(this) );
      console.log(aPos);
      //if aPos returns an array in console, use first val at pos zero to get row data
      var aData = oTable.fnGetData(aPos[0]);
      console.log(aData);
      // inspect your returned object, then tailor your $.each iteration
            $.each( aData["contributors"], function(i, data) {
                var ul_data = "<li><h3>"+ data+ "</h3></li>";
                $("#contributors_div").append(ul_data);
            });
       }
        $('#contributors_div').show();
       });
于 2013-07-04T00:37:31.570 回答