【问题标题】:Data Table Server Side Processing数据表服务器端处理
【发布时间】:2014-10-06 11:15:32
【问题描述】:

您好,我正在使用数据服务器端处理,

        $(document).ready(function() {

            $("#TABLE").dataTable({
            "bProcesing" : true,
            "bServerSide" : true,
            "bLenthChange" : false,
            "iDisplayLength" : 10,
            "bSort":false,
             "bFilter": true,
            "sAjaxSource" : "/easdaspp/abc",
            "aoColumns" : [
            {
            "sTitle" : "Organization Name",
            "mData" : "organizationName"
            },
            {
            "sTitle" : "Delete",
            "sDefaultContent" : '<a href="abc/{organizationId}" >Delete</a>'
            }],
            "fnServerData" : function(sSource, aoData, fnCallback) {
            $.ajax({
            "dataType" : 'json',
            "type" : "GET",
            "url" : sSource,
            "data" : aoData,
            "success" : fnCallback
            });
            },
            "sPaginationType" : "full_numbers"

            });// dataTable
             });

如何在锚标记中获取 organizationId 值 像这样

     "sDefaultContent" : '<a href="abc/{organizationId}" >Delete</a>'

应该是

       <a href="abc/1" >Delete</a>

每行以此类推,url的值应该根据我们改变

【问题讨论】:

  • 了解 js 替换和正则表达式。我没有看到任何困难
  • $("a").attr("href").trim().replace(/{value}/, jsonResponseValue); 然后将此值设置为 gref 属性,如$("a").attr("href", newHrefValue);
  • 我的意思是我如何获取 jsonResponseValue 我使用数据表查看我的修改代码

标签: javascript jquery json datatable jquery-datatables


【解决方案1】:

好吧,我用另一种方法自己看看 这是旧数据表的服务器端脚本

static function data_output($columns, $data) {
    $out = array();

    for ($i = 0, $ien = count($data); $i < $ien; $i++) {
        $row = array();

        for ($j = 0, $jen = count($columns); $j < $jen; $j++) {
            $column = $columns[$j];
            if ( $aColumns[$i] == "cId" ){
            /* Special output formatting for 'cId' column */

            $row[] = '
            <div id="trigger">
              <a target="_blank" title="Click to make Payment" href="viewDetails.php?cId='.$aRow[$aColumns[$i]].'">
                <img src="images/icons/color/rupee.png" />
              </a>
            </div>
            ';
           }
        }
     } 

【讨论】:

    【解决方案2】:

    我得到了使用 mRender 的解决方案,我们可以解决这个问题

    {"mData" : "organizationId",
                  "mRender": function ( data, type, full ) {
                  return '<a href="'+data+'">Download</a>';
                 }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-21
      相关资源
      最近更新 更多