Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何向jQuery数据表添加额外的列_Jquery_Jquery Ui_Jsp_Twitter Bootstrap_Datatables - Fatal编程技术网

如何向jQuery数据表添加额外的列

如何向jQuery数据表添加额外的列,jquery,jquery-ui,jsp,twitter-bootstrap,datatables,Jquery,Jquery Ui,Jsp,Twitter Bootstrap,Datatables,有人知道如何在jQuery数据表中添加额外的列吗?我有一个包含五列的jQuery数据表,我想再添加两列 <table class="table table-bordered table-striped table_vam" id="dt_gal"> <thead> <tr> <th class="table_checkbox"> <input type="chec

有人知道如何在jQuery数据表中添加额外的列吗?我有一个包含五列的jQuery数据表,我想再添加两列

<table class="table table-bordered table-striped table_vam" id="dt_gal">
    <thead>
        <tr>
            <th class="table_checkbox">
                <input type="checkbox" name="select_rows" class="select_rows" data-tableid="dt_gal" />
            </th>
            <th>Product Name</th>
            <th>Product Code</th>
            <th>Description</th>
            <th>Start Price</th>
            <th>Reg Fee</th>
            <th>DateCreated</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        <c:forEach var="product" items="${PRODUCTS}">
            <tr>
                <td>
                    <input type="checkbox" name="row_sel" class="row_sel" />
                </td>
                <td>${product.productname}</td>
                <td>${product.code}</td>
                <td>${product.description}</td>
                <td>${product.startPrice}</td>
                <td>${product.registrationFee}</td>
                <td>${product.dateCreated}</td>
                <td><a href="${PREFIX}/product?edit=true&id=${product.id}" class="sepV_a" title='Edit'><i class='icon-pencil'></i>
                                            Edit </a> 
                    <!-- <a href="#" title='Delete'><i class='icon-trash'></i></a></td> -->
            </tr>
        </c:forEach>
    </tbody>
</table>

这与jquery数据表和html无关,因为它将生成您定义的表结构

一列由

th
=表格标题单元格

td
=单元格

和线

tr
=行

如果你的桌子看起来像

<table>
 <tr>
   <th>Field1</th>
   <th>Field2</th>
   <th>Field3</th>
   <th>Field4</th>
   <th>Field5</th>
 </tr>
 <tr>
   <td>value1</td>
   <td>value2</td>
   <td>value3</td>
   <td>value4</td>
   <td>value5</td>
 </tr>
[...]
<table>

字段1
字段2
字段3
字段4
字段5
价值1
价值2
价值3
价值4
价值5
[...]
您需要为列标题添加2个
,为字段添加2个

<table>
 <tr>
   <th>Field1</th>
   <th>Field2</th>
   <th>Field3</th>
   <th>Field4</th>
   <th>Field5</th>
   <th>Field6</th>
   <th>Field7</th>
 </tr>
 <tr>
   <td>value1</td>
   <td>value2</td>
   <td>value3</td>
   <td>value4</td>
   <td>value5</td>
   <td>value6</td>
   <td>value7</td>
 </tr>
[...]
<table>

字段1
字段2
字段3
字段4
字段5
字段6
字段7
价值1
价值2
价值3
价值4
价值5
价值6
价值7
[...]

这与jquery数据表以及html无关,因为它将生成您定义的表结构

一列由

th
=表格标题单元格

td
=单元格

和线

tr
=行

如果你的桌子看起来像

<table>
 <tr>
   <th>Field1</th>
   <th>Field2</th>
   <th>Field3</th>
   <th>Field4</th>
   <th>Field5</th>
 </tr>
 <tr>
   <td>value1</td>
   <td>value2</td>
   <td>value3</td>
   <td>value4</td>
   <td>value5</td>
 </tr>
[...]
<table>

字段1
字段2
字段3
字段4
字段5
价值1
价值2
价值3
价值4
价值5
[...]
您需要为列标题添加2个
,为字段添加2个

<table>
 <tr>
   <th>Field1</th>
   <th>Field2</th>
   <th>Field3</th>
   <th>Field4</th>
   <th>Field5</th>
   <th>Field6</th>
   <th>Field7</th>
 </tr>
 <tr>
   <td>value1</td>
   <td>value2</td>
   <td>value3</td>
   <td>value4</td>
   <td>value5</td>
   <td>value6</td>
   <td>value7</td>
 </tr>
[...]
<table>

字段1
字段2
字段3
字段4
字段5
字段6
字段7
价值1
价值2
价值3
价值4
价值5
价值6
价值7
[...]

我在datatable.js中添加了以下内容,现在所有添加的列都可见

谢谢

            oTable = $('#dt_e').dataTable( {
            "bProcessing": true,
            "bServerSide": true,
            "sPaginationType": "bootstrap",
            "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
            "sAjaxSource": "lib/datatables/server_side.php",
            "aoColumns": [
                { "sClass": "center", "bSortable": false },
                **{ "sClass": "center" },
                { "sClass": "center" },
                { "sWidth": "20%" },
                { "sWidth": "20%" },
                { "sClass": "center" },
                { "sClass": "center" },
                { "sClass": "center" }**

            ],
            "aaSorting": [[1, 'asc']]
        } );
oTable=$('#dt_e')。数据表({
“bProcessing”:正确,
“bServerSide”:正确,
“sPaginationType”:“引导程序”,
“sDom”:“t”,
“sAjaxSource”:“lib/datatables/server_side.php”,
“aoColumns”:[
{“sClass”:“center”,“bSortable”:false},
**{“sClass”:“center”},
{“sClass”:“center”},
{“sWidth”:“20%”,
{“sWidth”:“20%”,
{“sClass”:“center”},
{“sClass”:“center”},
{“sClass”:“center”}**
],
“aaSorting”:[[1,‘asc']]
} );

我在datatable.js中添加了以下内容,现在所有添加的列都可见

谢谢

            oTable = $('#dt_e').dataTable( {
            "bProcessing": true,
            "bServerSide": true,
            "sPaginationType": "bootstrap",
            "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
            "sAjaxSource": "lib/datatables/server_side.php",
            "aoColumns": [
                { "sClass": "center", "bSortable": false },
                **{ "sClass": "center" },
                { "sClass": "center" },
                { "sWidth": "20%" },
                { "sWidth": "20%" },
                { "sClass": "center" },
                { "sClass": "center" },
                { "sClass": "center" }**

            ],
            "aaSorting": [[1, 'asc']]
        } );
oTable=$('#dt_e')。数据表({
“bProcessing”:正确,
“bServerSide”:正确,
“sPaginationType”:“引导程序”,
“sDom”:“t”,
“sAjaxSource”:“lib/datatables/server_side.php”,
“aoColumns”:[
{“sClass”:“center”,“bSortable”:false},
**{“sClass”:“center”},
{“sClass”:“center”},
{“sWidth”:“20%”,
{“sWidth”:“20%”,
{“sClass”:“center”},
{“sClass”:“center”},
{“sClass”:“center”}**
],
“aaSorting”:[[1,‘asc']]
} );

您使用的是服务器端数据源还是客户端数据源?您要添加的两列是数据源的一部分还是任意列?另外,您可以发布您的
dataTable
configuration部分吗。我正在使用jquery.datatables.bootstrap.min.js,我在上面的一个.jsp文件中发布了一个示例。您是否已经为您的问题确定了一个可接受的解决方案?嗨,皮特,是的..您是否已经使用服务器端或客户端数据源发布了解决方案?您要添加的两列是数据源的一部分还是任意列?另外,您可以发布您的
dataTable
configuration部分吗。我正在使用jquery.datatables.bootstrap.min.js,我已经在一个.jsp文件中发布了上面的示例。您是否已经为您的问题确定了一个可接受的解决方案?嗨,皮特,是的..已经发布了解决方案hi G.Mendes,我已经完成了上面的操作,但仍然没有显示该表。我在问题中添加了一个示例。Thanks@pmaingi我不认为问题出在
fnUpdate
选项中,您可以发布
datatable
config的其余部分吗?还要注意的是,您对操作rowsHi G.Mendes上的
td
关闭每一行进行了注释。我已经完成了上述操作,但仍然没有显示该表。我在问题中添加了一个示例。Thanks@pmaingi我不认为问题出在
fnUpdate
选项中,您可以发布
datatable
config的其余部分吗?还要注意,您对操作行上的
td
关闭每一行进行了注释