0

查询

{   
$(document).ready(function() {
   $("#search_btn").click(function() {
var _empID = document.getElementById('search').value;
$.ajax({
  url: 'coinsIndentsServlet?empid=' + _empID,
  type: 'GET',
  dataType: 'json',
  timeout: 2500,
  "columns": [{
    "data": "INDENTNO",
    "render": function(data, type, row, meta) {
      return '<a href="Angularhtml.html?INDENTNO=' + data + '">' + data + '</a>';
    }
  }],
  success: function(response) {
    $('#table').bootstrapTable('load', response.indents);
    $('#tabledata').bootstrapTable('load', response.egps);
  }
  });
  });
  });
}

桌子

{
  <div class="container">
        <span style="float: top; font-family: cursive ;background-color: powderblue;"><h4><b><I>COINS 
    INDENT DETAILS</i></b></h4></span>
        <table  id ="table" data-toggle="table"
                data-pagination="true"  class="table
                table-striped
                table-bordered
                table-hover
                display" >

            <thead>
                <tr >

                    <th data-field="INDENTNO"><b>INDENT NO</b></th>
                    <th data-field="INDENTSHORTDES"><b>INDENT DESCRIPTION</b></th>
                    <th data-field="INDENTDATE"><b>INDENT DATE</b></th>
                    <th data-field="REGSTATUS"><b>STATUS</b></th>
                </tr>
            </thead>
        </table>
    </div>
}

在这里,我想要一列 INDENT NO 被超链接,我有上面的代码,但它不起作用。在这里,我使用材料设计引导程序和 JQueryH。谁能建议如何只超链接表中的一列。

4

1 回答 1

0

您所拥有的内容如下,您在columns选项中设置渲染选项ajax,这不会做任何事情,这应该在列属性响应的选项中。

$.ajax({
  url: 'coinsIndentsServlet?empid=' + _empID,
  type: 'GET',
  dataType: 'json',
  timeout: 2500,
  "columns": [{
    "data": "INDENTNO",
    "render": function(data, type, row, meta) {
      return '<a href="Angularhtml.html?INDENTNO=' + data + '">' + data + '</a>';
    }
  }],
  success: function(response) {
    $('#table').bootstrapTable('load', response.indents);
    $('#tabledata').bootstrapTable('load', response.egps);
  }
  });

下面是列渲染/格式化程序的通用语法

<th data-field="INDENTNO" data-formatter="somefunction"><b>INDENT NO</b></th>

在脚本中

 function somefunction(index, row) {
    /* create hypherlink here as per  your need*/
    return index + '. Item ID: ' + row.id
  }

参考: https ://live.bootstrap-table.com/example/column-options/formatter.html#view-source

示例: https ://live.bootstrap-table.com/example/column-options/formatter.html

于 2020-10-12T07:21:54.787 回答