jQWidgets Forums

jQuery UI Widgets Forums Grid Binding Image from Database

This topic contains 3 replies, has 3 voices, and was last updated by  Peter Stoev 11 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Binding Image from Database #3862

    amitabha82
    Member

    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.

    Binding Image from Database #3890

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Binding Image from Database #49419

    Gopre400
    Participant

    Hi Peter,

    I looked at pinnedcolumns.htm but I didn’t see any column that was bound to an image, am I missing something?

    Thanks
    John

    Binding Image from Database #49433

    Peter Stoev
    Keymaster

    Hi John,

    The Topic is from 2012. The demo is updated. We do not have such sample anymore.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.