locked
Image formatter in jqgrid RRS feed

  • Question


  • In my JQGrid one of my column is image and image formatter is not taking right image path.
    i have used like this :

     function imageFormat(cellvalue, options, rowObject) {
          return '<img src="~/Content/images/' + cellvalue + '" />';
    }
    and called like this ::
    { name: 'CategoryImageName', index: 'CategoryImageName', width: 60, align: "center", editable: true, formatter: imageFormat }

    Its not taking correct image path.
    Please  help me.
    Thanks in advance.

    DevSD4

    Friday, August 30, 2013 6:10 AM

All replies

  • After my 2days of R&D,got this solution.

    May someone will get help.

        var v = "@Url.Content(Convert.ToString("~/content/images/"))" + cellvalue;
                return "<img src =" + v + "  />";

    In image formatter,first collect image source(path) using @Url.Content() and then append to source.


    DevSD4

    Monday, September 2, 2013 9:38 AM