我正在使用Jquery Grid使用Jquery Grid获取图像到目前为止我从服务器获取图像路径但我不知道如何在图像源中显示图像。
$(document).ready(function() {
// prepare the data
var theme = 'classic';
var imagerenderer = function(row, datafield, value) {
return '<img style="margin-left: 5px;" height="60" width="50" src="' + value + '"/>';
}
var source =
{
datatype: "json",
datafields: [
{name: 'ID'},
{name: 'name'}
],
url: 'PaginationForWhiteAndBlackList.php',
root: 'Rows',
beforeprocessing: function(data)
{
source.totalrecords = data[0].TotalRows;
}
};
var dataadapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 600,
source: dataadapter,
theme: theme,
autoheight: true,
pageable: true,
virtualmode: true,
rendergridrows: function()
{
return dataadapter.records;
},
columns: [
{text: 'ID', datafield: 'id', width: 250},
{text: 'Name', datafield: 'image', width: 200, cellsrenderer: imagerenderer}
]
});
});