2016-01-20 100 views
0

我有以下數據表定義:在數據表列顯示的圖像

$("#tblSteps").dataTable({ 
     sAjaxSource: '@Url.Action("GetAllOpenCandidateSteps")?' + "candidateId=" + $("#txtCandidateId").val(), 
     bJQueryUI: true, 
     dom: 'T<"clear">rti', 
     bAutoWidth: false, 
     "bPaginate" : false, 
     "oLanguage": { 
      sEmptyTable: "There are no Steps at this time" 
     }, 
     "aoColumns": [ 
      { "sWidth": "1%", sClass: "smallFonts" }, 
      { "sWidth": "1%", sClass: "smallFonts" }, 
      { "sWidth": "5%", sClass: "smallFonts" }, 
      { "sWidth": "19%", sClass: "smallFonts" }, 
      { "sWidth": "19%", sClass: "smallFonts" }, 
      { "sWidth": "19%", sClass: "smallFonts" }, 
      { "sWidth": "19%", sClass: "smallFonts" }, 
      { 
       "sWidth": "19%", sClass: "smallFonts", "sName": "CandidateId", "mRender": function (data, type, row) { 
        var chk = row[7] == 'True' ? ' checked="true" ' : ' '; 
        var chk1; 
        if (chk === ' ') 
         chk1 = "false"; 
        else 
         chk1 = "true"; 
        if (chk1 == "true") { 
         return "<img height='16' width='16' src='/Images/yes.gif'></img><label style='font-size:x-small'>Complete</label>"; 
        } 
        else { 
         return "<img height='16' width='16' src='/Images/button_red.png'></img><label style='font-size:x-small'>Not Complete</label>"; 
        } 
        //return "<input type='checkbox'" + chk + " id='chkuar" + row[0] + "' onchange=approved('" + row[0] + "','" + row[1] + "'," + chk1 + "); >"; 
       } 
      } 
     ], 
     tableTools: { 
      "sSwfPath": "../../Scripts/swf/copy_csv_xls_pdf.swf", //'<c:url value="../../scripts/swf/copy_csv_xls_pdf.swf"/>', //"//cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf", // 
      "aButtons": [ 
       { 
        "sExtends": "print", 
        "bShowAll": true 
       } 
      ] 

     } 
    }); 

你會在最後一欄看到我在圖片文件夾中顯示圖像。這顯示在我的DEV盒子上使用Casinni,但不在服務器上。任何想法我做錯了什麼?

+0

可能看起來很明顯,但在服務器上肯定是圖像? – markpsmith

+0

@markpsmith - 是的,我可以在Images文件夾中看到它們。 –

+0

你能看到爲圖像渲染的HTML嗎?路徑錯了嗎? – markpsmith

回答

1

好像圖像是從錯誤的URI中拉出來的;如果表格位於具有以下URI的頁面上:http://<example.com>/<someDirectory>/且圖像位於此URI:http://<example.com>/Images/yes.gif那麼圖像的正確src應該爲:../Images/yes.gif以反映目錄層次結構。很高興它幫助;-)