我正在尝试使用 DataTable 插件在表中创建一列,该列是使用前两列的值计算的。
像这样的东西..(价格)(数量)=总计
|| Price || QTY || Total||
==========================
|| 5 || 2 || 10 ||
|| 10 || 3 || 30 ||
|| 4 || 1 || 4 ||
我觉得它应该很简单,但我无法让它发挥作用。这是我试图遵循的类似问题。 https://datatables.net/forums/discussion/25675/how-to-display-computed-column-dynamically-using-jquery-datatables
这是我正在初始化表的 JS 文件
var table = $('#tempPOs').DataTable( {
dom: 'frtip', //Bfrtip (removed the B to get rid of the buttons)
ajax: '/inventory/DTResources/php/table.tempPOs.php',
columns: [
{ "data": "pmkPart" },
{ "data": "PartNumber" },
{ "data": "Description" },
{ "data": "fnkManufacturer" },
{ "data": "Notes" },
{ "data": "EachPrice", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },
{ "data": "Quantity" },
{ "data": "Username" },
{
data: null,
className: "center",
defaultContent: '<a href="" class="editor_remove">Remove</a>'
}
],
select: true,
lengthChange: false,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
],
} );
这是我的 HTML
<th>Part ID</th>
<th>Part Number</th>
<th>Description</th>
<th>Manufacturer</th>
<th>Notes</th>
<th>Part Price</th>
<th>Quantity</th>
<th>Username</th>
<th>Total Price</th>
<th>Remove</th>
有人能指出我正确的方向吗?