创建DataTable的代码
var MCCntrctrTable = S$('#tblMCSelVndr').DataTable({
"sPaginationType": "full_numbers",
"aoColumns": [
{ "sTitle": "Vendor ID", "mData": "VendorID", "sWidth": "19%" },
{ "sTitle": "Contractor Legal Name", "mData": "CNTRCTR_NM", "sWidth": "40%" },
//{ "sTitle": "Work Type", "mData": "CNTRCT_WorkTyp", "sWidth": "20%" },
{ "sTitle": "Address ", "mData": "ADDR", "sWidth": "40%" },
{ "sTitle": "", "mData": "CNTROR_ADDR_ID", "sWidth": "1%" },
{ "sTitle": " ", "mRender": function (data, type, full) { return '<button>ADD</button>' }, "sWidth": "10%", "sClass": "center" }
],
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"bSort": true,
"aaSorting": [],
"bStateSave": true,
"data": data,
"bJQueryUI": true,
"bAutoWidth": false,
"columnDefs": [
{
"targets": [3],
"visible": false
}, ]
});
点击行中的按钮时调用
S$('#tblMCSelVndr tbody').on('click', 'button', function (e) {
debugger;
var data = MCCntrctrTable.row(S$(this).parents('tr')).data();
//MCCntrctrTable.eq(0).attr('disabled')
newCNTRList = [];
if (data) {
var cntrctrToAdd = {
CNTRCNTRCTRID: '',
CntrctrAddID: data.CNTROR_ADDR_ID,
VedorID: data.VendorID,
LegalName: data.CNTRCTR_NM,
CntrctrAddr: data.ADDR,
ProgID: data.ProgID,
CatID: data.CLCat_ID,
SelMethod: S$("#SelectionMethod").val(),
SelMethodName: S$("#SelectionMethod option:selected").text()
}
debugger;
newCNTRList.push(cntrctrToAdd);
}
//remove contractor from dataTable
S$(this).attr('disabled', 'disabled');
});
当我第一次单击表格行中的“添加”按钮时,该特定行的“添加”按钮将被禁用。 现在,如果我在其他行中单击其他添加,则应启用先前禁用的按钮。为此,我必须找到表中禁用的按钮。 我尝试了几种可能性,例如
S$('#tblMCSelVndr tbody').eq(0).attr('disabled')
S$('#tblMCSelVndr tbody').find('tr td disabled')
他们都没有工作!