How to get image src value from server side jquery datatable in datatable?

Floki

I am using jquery datatable and filling that datatable with ajax call and its working fine but now i need to shows the images in a column but i m don't know how to bind these images.Image link is coming from backend in category_image.

Back End:

var displayedCategories = filteredCategories;
var result = from c in displayedCategories select new[] 
{c.id, c.category_name, c.category_image,c.id};
return Json(new{
sEcho = param.sEcho,
iTotalRecords = lstAllCategories.Count,
iTotalDisplayRecords = 10,
aaData = result},JsonRequestBehavior.AllowGet);

Front End:

$('#tblInterests').dataTable({
"bServerSide": true,
"sAjaxDataProp": "aaData",
"bProcessing": true,
"bLengthChange": false,
"sPaginationType": "full_numbers",
"bSort": true,
"aoColumns":[
{"sName": "id"},
{"sName": "category_name" },
{"sName": "category_image",
"bSearchable": false,
"bSortable": false,
"mRender": function (data) {
return '<img src="" width="50" height="50" />'
}
},
{"mData": "Id",
"bSearchable": false,
"bSortable": false,
"sWidth": "40px",
"mRender": function (data) {
return '<button class="btn btn-primary" type="button" >Edit</button>'
}
},
],
"ajax": "/Admin/InterestsJson",
"columns": [
{ "data": "id" },
{ "data": "category_name" },
{ "data": "category_image" },
{ "data": "id" }
]
});
davidkonrad

in mRender, data (==category_image) should be set as src for the image :

...
{ "sName": "category_image",
  "bSearchable": false,
  "bSortable": false,
  "mRender": function(data, type, full) {
     return '<img src="'+data+'" width="50" height="50" />'
  }
}
...

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

Formatting server side jQuery Datatable

jquery datatable - how to get a value from a selected row

How to send custom data to DataTable server-side processing not from DataTable's filter input?

How to get a single row data from a jquery datatable?

Is there a way to get aocolumns from the server in datatable editable?

How to show data from get request in datatable?

PrimeNG DataTable server-side paging

Update Jquery Datatable Cell Value

jQuery : How To Get src Value of Multiple img

How to get image src from specific element

How to edit a cell and delete a row from dataTable at serverside processing jquery

How can I adjust the columns after initializing server-side processing datatable?

DataTable Get Value of a Row under a Column Value

Jquery datatable hide column but access its value

Get selected rows first column value in datatable

how to update empty datatable by the data from another datatable

React DataTable value from Nested Array

Hide Button From Last Row In A DataTable - JQuery

c# Get ID from datatable on login

get repeated data from datatable c#

How to sort Datatable by days in string value

datatable jquery how to see data of the table in console

How to add text between jquery datatable pagination

jQuery : How to bind an onClick Event to a DataTable row?

How to get the last row of Google DataTable in javascript?

Through jQuery get the image clicked src and put in another image src

How to pull data out from datatable

how to insert data into datatable from variable

How to create an object from a Datarow of Datatable in Flutter