I want to display an image from a database in my Bootgrid table, and I know that I have to use formatters. But I don't know how? Here is an example of my Bootgrid table and side server code:
var productTable = $('#data').bootgrid({
ajax: true,
rowSelect: true,
post: function () {
return {
id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
};
},
url: "load_data.php",
formatters: {
"commands": function (column, row) {
return "<button type='button' class='btn btn-warning btn-xs update' data-row-id='" + row.book_id + "'>Edit</button>" + " <button type='button' class='btn btn-danger btn-xs delete' data-row-id='" + row.book_id + "'>Delete</button>";
},
}
});
Here is my server-side code:
$query .= "SELECT book.data_id,
category.category_name,
book.data_name,
book.data_quotes,
book.image
FROM product
INNER JOIN category
ON category.category_id = book.category_id ";
Here is the thing: I receive the data from my PHP file in JSON data type (json_encode
), and that puts me in a much worse position.