2016-08-09 14 views
0

Ich habe diesen vollständigen Code des Gitters. Wie Sie in diesem PICTURE sehen können, habe ich einen Bildschaltflächentyp innerhalb eines jqgrid. Ich möchte, dass die Bild-Schaltfläche von Status deaktiviert ist, ist nicht Pending, wenn es in Pending Status ist die Schaltfläche/s sind aktiviert. Für den Code unten versuche ich *.attr("disabled",true); funktioniert nicht Ich kann immer noch auf meine Schaltfläche klicken und es löst die Funktion aus. Ich benutze <= jquery 1.8.2 Version von jquery.Wie man Bildknopf in Javascript abstellt?

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"); 
      } 
     } 
    }); 

Wenn ich *.prop("disabled",true) verwenden habe ich diesen Fehler Uncaught TypeError: $(...).prop is not a function

Antwort

0

An alle, die meinen Beitrag sehe ich eine Lösung gefunden. Ich sollte es von Anfang an versuchen, aber ich bin, wenn es funktioniert. Aber jetzt löst es mein Problem.

Hier ist meine Antwort, die ich nur hinzufügen, 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 + ")' />"

und nun seine Arbeit gut.