c# - How to get image src value from server side jquery datatable in datatable? -
i using jquery datatable , filling datatable ajax call , working fine need shows images in column m don't know how bind these images.image link coming backend in category_image.
back end:
var displayedcategories = filteredcategories; var result = 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" } ] });
in mrender
, data
(==category_image
) should set src
image :
... { "sname": "category_image", "bsearchable": false, "bsortable": false, "mrender": function(data, type, full) { return '<img src="'+data+'" width="50" height="50" />' } } ...
Comments
Post a Comment