簡體   English   中英

如何從Jquery DataTable 1.10.12獲取Hidden列值

[英]How to get the Hidden column value from Jquery DataTable 1.10.12

如何從JQUERY數據表中獲取隱藏的列值PID,以將URL傳遞到另一個.aspx頁,在此我可以在FirmsDeatils.aspx頁中顯示人員和公司的詳細說明。 任何幫助都很好。

<script type="text/javascript">
   $(document).ready(function() {
   $.ajax({
  // url: 'FirmDetailService.asmx/GetFirmDetails',
  url: '<%= ResolveUrl("FirmDetailService.asmx/GetFirmDetails")%>',
  method: 'post',
  dataType: 'json',
  success: function(data) {
    $('#example').DataTable({

      //paging:false,
      //ordering : false,
      searchHighlight: true,
      lengthChange: false,
      data: data,
      columns: [{
        'data': 'PID',
        visible: false
      }, {
        'data': 'PersonName',
        'render': function(PersonName) {
          var id = ? ? ? ? ;
     return "<a href= FirmsDeatils.aspx?=" + id + '>' + PersonName + '</a>';
        }

      }, {
        'data': 'CID',
        visible: false
      }, {
        'data': 'CompanyName'
      }, {
        'data': 'City'
      }, {
        'data': 'Country'
      }, ]
    });
    }
    });

   });
  </script>
 </head>

<body>
 <table id="example" class="display" cellspacing="0" width="100%">
 <thead>
  <tr>
    <th>PID</th>
    <th>PersonName</th>
    <th>CID</th>
    <th>CompanyName</th>
    <th>City</th>
    <th>Country</th>
   </tr>
  </thead>
 </table>
</body>

 </html>

使用以下代碼:

'render': function(data, type, row, meta) {
    var id = row['PID'];
    return '<a href="FirmsDeatils.aspx?=' + id + '">' + data + '</a>';
}
<script type="text/javascript">
$(document).ready(function () {

    $.ajax({
        // url: 'FirmDetailService.asmx/GetFirmDetails',
        url: '<%= ResolveUrl("FirmDetailService.asmx/GetFirmDetails")%>',
        method: 'post',
        dataType: 'json',
        success: function (data) {
       $('#example').DataTable({

                //paging:false,
                //ordering : false,
                searchHighlight: true,
                lengthChange:false ,
                data: data,
                'columns': [
                         { 'data':'PID', 'visible' : false},

                         {'data' : 'PersonName',
                         'render': function (data, type, row, meta) {
                             var id = row['PID'];
          return '<a href="FirmsDeatils.aspx?=' + id + '">' + data + '</a>';
                         }

                    },
                    { 'data': 'CID', 'visible' :false },
                    { 'data': 'CompanyName'},
                    { 'data': 'City' },
                    { 'data': 'Country' },
                ]

       }

            );

        }
    });
 }
  );
 </script>
<body>
<table id="example" class="display"  cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>PID</th>
            <th>PersonName</th>
            <th>CID</th>
            <th>CompanyName</th>
            <th>City</th>
            <th>Country</th>
        </tr>
    </thead>
</table>
</body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM