我想在我的数据表中显示图像。请注意,我可以显示数据表中除图像之外的所有数据。我在我的应用程序中使用ASP.NET MVC 5。这是我的jQuery代码:
$(document).ready(function () {
var oTable = $('#tblPromobanner').DataTable({
"ajax": {
"url": "/PromoBanner/loaddata",
"type": "GET",
"datatype": "json"
},
"responsive": true,
"columns": [
{ "data": "DepartmentID", "autoWidth": true },
{ "data": "ContentId", "autoWidth": true },
{ "data": "nav_url", "autoWidth": true },
//{ "data":"img_src", render: getImg }
{
"data": "img_src",
"render": function (url, type, full) {
return '<img height="75%" width="75%" src="' + full[3] + '"/>';
}
}
]
});
这是我的控制器代码
public ActionResult loaddata()
{
db.Configuration.LazyLoadingEnabled = false;
var clientes = db.Promobanner.ToList();
return Json(new { data = clientes }, JsonRequestBehavior.AllowGet);
}