我已经用 jQuery 数据表构建了一个表,我想要一个按钮来执行一个函数。
到目前为止,我可以让按钮进入 jquery 函数,但它们总是通过参数 null 传递。
我正在尝试将 GoodNumberId 传递给函数。
function GetGoods() {
$.post("GetGoods", function (GoodsDS) {
var obj = jQuery.parseJSON(GoodsDS);
var table = obj.Table;
$('#demo').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>');
$('#TableWrapper').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDeferRender": true,
"aaData": table
,
"aoColumns": [
{ "mDataProp": "GoodNumberId", "sTitle": "Goods ID" },
{ "mDataProp": "SerialNumber", "sTitle": "Serial Number" },
{ "mDataProp": "Make", "sTitle": "Make" },
{ "mDataProp": "Model", "sTitle": "Model" },
{ "mDataProp": "Description", "sTitle": "Description" },
//{ "mDataProp": "IMEINumber", "sTitle": "IMEINumber" },
{ "mDataProp": "Condition", "sTitle": "Condition" },
// { "mDataProp": "DistinguishingMarks", "sTitle": "DistinguishingMarks" },
// { "mDataProp": "OtherFeatures", "sTitle": "OtherFeatures" },
//{ "mDataProp": "Status", "sTitle": "Status" },
{ "mDataProp": "ItemStatus", "sTitle": "Item Status" },
{ "mDataProp": "Price", "sTitle": "Price" },
{ "mDataProp": "TransactionDate", "sTitle": "Transaction Date" },
//{ "mDataProp": "TransactionTypeId", "sTitle": "TransactionTypeId" },
{"mDataProp": "TransactionDescription", "sTitle": "Transaction" },
{ "mData": null,
"bSortable": false,
"mRender": function (GoodNumberId) { return '<input id="btnDispose" type="button" onclick="Dispose(' + GoodNumberId +')" value="Dispose" />'; }
}
]
});
});
};
表变量如下所示:
我需要每个按钮来传递它当前行的 ID 吗?