ParamQuery grid support forum

General Category => ParamQuery Pro Evaluation Support => Topic started by: Ajay on November 03, 2015, 08:13:07 pm

Title: Facing issue while trying to retrieve image in grid cell.
Post by: Ajay on November 03, 2015, 08:13:07 pm
Hi,

I am trying to retrieve image in PQ Grid.
From the code, I am getting byte array.
so i converted back to base64string and tried to display,but the image is not displaying properly.
Here is my Code,

Please let me know If I am missing anything.

searchNhidGrid = $('#searchNhidGrid');
        var columnModel = [
                           { title: " Application name", dataIndx: "Name", width: 150, align: "left" },
                           { title: " Application description", dataIndx: "Description", width: 150, align: "left" },
                           {
                               title: "Application icon/logo", dataIndx: "Image", width: 150, align: "left",
                               render: function (ui) {
                                   var rowData = ui.rowData,
                                       dataIndx = ui.dataIndx,
                                       cellData = rowData[dataIndx];
                                   if (typeof cellData === "undefined")
                                       return "<span ></span>";
                                   else {
                                       var imageDisplay = cellData;
                                       var base64 = base64js.fromByteArray(imageDisplay); //converting bytearray to base64 string

                                       return '<img src="data:image/jpeg;base64,"' + base64 + '></img>';
                                       
                                   }
                               }
                           },
                           { title: "Application Status", dataIndx: "Status", width: 150, align: "left" },
                           { title: "Partner GUID", dataIndx: "PartnerGuid", width: 150, align: "left" }
        ];
        searchNhidGrid.pqGrid({
            width: NMCApp.getSearchGridWidth(),
           height: NMCApp.getSearchGridHeight(),
            editable: false,
            showTop: false,
            showBottom: false,
            hoverMode: 'row',
            selectionModel: { type: 'row', mode: 'single' },
            numberCell: false,
            roundCorners: false,
            wrap: false,
            colModel: columnModel,
            dataModel: { data: [] }
        });
Title: Re: Facing issue while trying to retrieve image in grid cell.
Post by: paramvir on November 04, 2015, 11:13:04 am
It looks like improper closing of quotes of src attribute in your img tag

Code: [Select]
return '<img src="data:image/jpeg;base64,"' + base64 + '></img>';

should be

Code: [Select]
return '<img src="data:image/jpeg;base64,' + base64 + '" />';
Title: Re: Facing issue while trying to retrieve image in grid cell.
Post by: Ajay on November 06, 2015, 12:05:05 pm
Thanks for the help.