jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Binding Image from Database
Tagged: jqxGrid Image Binding
This topic contains 3 replies, has 3 voices, and was last updated by Peter Stoev 11 years, 3 months ago.
-
Author
-
I am using jqxgrid in asp.net mvc3.I want to bind images to the grid view column.Images are stored in sql server database as binary data.
Table Structure:
CategoryID int PK
CategoryName varchar
Description varchar
Picture Image
But when I am running the application it wants to download something without displaying anything.I am giving my code below.
@model IEnumerable@{
ViewBag.Title = “Index”;
}Index
@Html.ActionLink(“Create New”, “Create”)
$(document).ready(
function () {
var theme=’energyblue’
var data = {
datatype:”json”,
datafields:[
{name:’CategoryID’},
{name:’CategoryName’},
{name:’Description’},
{name:’Picture’},],
url:’Category/Index’};
var editrowindex = -1;
$(‘#jqxgrid’).jqxGrid(
{
width: 1000,
source: data,
theme: ‘energyblue’,
sortable: true,
pageable: true,
autoheight: true,
columns: [
{ text: ‘CategoryID’, datafield: ‘CategoryID’, hidden: ‘true’ },
{ text: ‘CategoryName’, datafield: ‘CategoryName’, width: 250 },
{ text: ‘Description’, datafield: ‘Description’, width: 250 },
{ text: ‘Picture’, datafield: ‘Picture’, width: 150,cellsrenderer: imagerenderer },{ text: ‘Edit’, datafield: ‘Edit’, columntype: ‘button’, width: 150, cellsrenderer: function () {
return “Edit”;
}, buttonclick: function (row) {editrowindex = row;
var id = $(“#jqxgrid”).jqxGrid(‘getcellvalue’, row, “CategoryID”);
alert(id);
//// window.location = ‘/Customer/Edit/?id=’ + id;
}
}]
});
}
);
Event Log:Paging Details:My controller Code is :
public class CategoryController : Controller
{
private NorthwindEntities db = new NorthwindEntities();//
// GET: /Category/public JsonResult Index()
{
var categoryresult = db.Categories.ToList();
var categories = from Category in categoryresult
select new { Category.CategoryID, Category.CategoryName, Category.Description, Category.Picture };
return Json(categories, JsonRequestBehavior.AllowGet);
}
}Plz Help me.
Hi amitabha82,
I suggest you to take a look at the implementation of this sample: pinnedcolumns.htm. The Grid loads images In the second column of the Grid in the sample.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I looked at pinnedcolumns.htm but I didn’t see any column that was bound to an image, am I missing something?
Thanks
JohnHi John,
The Topic is from 2012. The demo is updated. We do not have such sample anymore.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.