我有完整的网格代码。正如您在此PICTURE中所看到的,我在jqgrid中有一个图像按钮类型。我希望图片按钮被禁用Status
不是Pending
,如果它处于Pending
状态,则按钮被启用。对于下面的代码,我尝试*.attr("disabled",true);
不起作用我仍然可以单击我的按钮,它会触发该功能。我使用的是<= jquery 1.8.2
版本的jquery。
function FiTATimeCorrectionV2(FAId, drpStatus) {
var url1 = '../Request/GetFitaTimeCorrectionV2?FAId=' + FAId + '&drpStatus=' + drpStatus;
$("#FiTATimeCorrectionV2List").jqGrid({
url: url1,
datatype: 'json',
mtype: 'POST',
colNames: ['rowId', 'FitaAssignDtlID', 'FitaAssignID', 'Date', 'Time In1', 'Time Out1', 'Time In2', 'Time Out2', 'Time In1', 'Time Out1', 'Time In2', 'Time Out2', 'Remarks', 'Status', '', ''],
colModel: [
{ name: 'rowId', index: 'rowId', hidden: true, width: 20 },
{ name: 'FitaAssignDtlID', index: 'FitaAssignDtlID', hidden: true, editable: true, sortable: false, width: 20, align: 'center' },
{ name: 'FitaAssignID', index: 'FitaAssignID', hidden: true, editable: true, sortable: false, width: 90, align: 'center' },
{ name: 'Date', index: 'Date', hidden: false, editable: true, sortable: false, width: 85, align: 'center' },
{ name: 'FitaIn1', index: 'FitaIn1', width: 70, align: 'center' },
{ name: 'FitaOut1', index: 'FitaOut1', width: 70, align: 'center' },
{ name: 'FitaIn2', index: 'FitaIn2', width: 70, align: 'center' },
{ name: 'FitaOut2', index: 'FitaOut2', width: 70, align: 'center' },
{ name: 'FitaCorIn1', index: 'FitaCorIn1', width: 70, align: 'center' },
{ name: 'FitaCorOut1', index: 'FitaCorOut1', width: 70, align: 'center' },
{ name: 'FitaCorIn2', index: 'FitaCorIn2', width: 70, align: 'center' },
{ name: 'FitaCorOut2', index: 'FitaCorOut2', width: 70, align: 'center' },
{ name: 'FitaCorRemarks', index: 'FitaCorRemarks', width: 73, align: 'center' },
{ name: 'FitaStatus', index: 'FitaStatus', width: 70, align: 'center' },
{ name: 'FitaCorForApproval', index: 'FitaCorForApproval', width: 50, align: 'center' },
{ name: 'FitaCorForDisApproval', index: 'FitaCorDisForApproval', width: 50, align: 'center' },
],
pager: $('#FiTATimeCorrectionV2Pager'),
rowNum: 5,
rowList: [5, 10, 20],
sortname: 'FADate',
sortorder: 'desc',
viewrecords: true,
imgpath: '/Content/themes/redmond/images/',
height: '100%',
afterInsertRow: function (rowid) {
var obj = jQuery("#FiTATimeCorrectionV2List").getRowData(rowid);
var FADTLSID = obj.FitaAssignDtlID;
if (FADTLSID !== undefined) {
if (FADTLSID !== "") {
var btnApprove = "<img alt='' src='../../Content/Images/newimages/check.png' style='height:20px;width:20px;' style ='width: 90px' id='btnApproved" + rowid + "' onclick='clickmeapproved(" + rowid + " )' />"
var btnDisApprove = "<img alt='' src='../../Content/Images/newimages/delete.png' style='height:20px;width:20px;' style ='width: 90px' id='btnDisApproved" + rowid + "' onclick='clickmedisapproved(" + rowid + " )' />"
jQuery("#FiTATimeCorrectionV2List").setRowData(rowid, { FitaCorForApproval: btnApprove });
jQuery("#FiTATimeCorrectionV2List").setRowData(rowid, { FitaCorForDisApproval: btnDisApprove });
var temp = obj.FitaStatus;
if (temp == "Approved") {
$("#btnApproved" + rowid).attr("disabled", true);
$("#btnDisApproved" + rowid).attr("disabled", true);
}
else if (temp == "Disapproved") {
$("#btnApproved" + rowid).hide();
$("#btnDisApproved" + rowid).hide();
} else {
$("#btnApprove" + rowid).attr("disabled", false);
$("#btnDisApprove" + rowid).attr("disabled", false);
}
}
}
},
loadComplete: function () {
var ids = jQuery("#FiTATimeCorrectionV2List").getDataIDs();
var len = ids.length;
if (len < 5) {
AddNewRowToGrid(len, "#FiTATimeCorrectionV2List");
}
}
});
如果我使用*.prop("disabled",true)
,我收到此错误Uncaught TypeError: $(...).prop is not a function
答案 0 :(得分:0)
对于查看我帖子的所有人,我找到了解决方案。我应该从一开始就试一试,但是如果它能起作用的话。但现在它解决了我的问题。
以下是我的答案,我只需添加input type='image'
var btnApprove = "<input type = 'image' img alt='' src='../../Content/Images/newimages/check.png' style='height:20px;width:20px;' style ='width: 90px' id='btnApproved" + rowid + "' onclick='clickmeapproved(" + rowid + " )' />"
现在工作正常。