Good day, all:
I am trying to use the render function to display an imagebutton in a column given a value returned in each data row (much like the example given on the demo site with the up and down arrows). I am evaluating whether a column's value equals one of two values; if the value is 1, then display the image button, if it's 0 (zero), display nothing. The problem is that either all rows get an image button or none of them do, depending on how I write the condition. Here is the code:
$(function () {
var obj = {
width: 580,
height: 700,
wrap: false,
hwrap: false,
editable: false,
showTop: false,
showBottom: false,
collapsible: false,
showHeader: true,
resizable: true,
columnBorders: true,
rowBorders: true,
flexHeight: true,
virtualX: false,
sortable: false,
numberCell: { show: true },
filterModel: { mode: "AND", header: true },
scrollModel: { autoFit: true, pace: 'optimum' },
selectionModel: { type: 'row', mode: 'single' },
title: "Report Periods",
colModel: [
{ title: "ReportPeriodId", dataType: "integer", dataIndx: "ReportPeriodId", hidden: true },
{ title: "Report Date", width: 75, dataType: "string", dataIndx: "ReportPeriodName" },
{ title: "Date Span", width: 75, dataType: "string", dataIndx: "ReportPeriodDtSpan" },
{ title: "Upload Available", dataType: "integer", dataIndx: "UploadAvailable" },
{
title: "", editable: false, sortable: false, width: 100, align: "center", render: function (ui) {
var rowData = ui.rowData;
if (rowData[3] = 1) {
return "<input type='image' src='../../images/1450567121_editor-pencil-pen-edit-write-glyph.ico' onClick=\"location.href='..." + rowData.ReportPeriodId + "';\" title='Edit Info' width='20' height='20'>";
}
else
{
return "";
}
}
}
],
dataModel: {
dataType: "JSON",
location: "remote",
recIndx: "ReportPeriodId",
url: "/Home/ReportPeriodsByAcademicYear",
getData: function (dataJSON) {
return { data: dataJSON.data };
}
},
pageModel: { type: 'local', rPP: 20 }
}
var grid = $("#grid_ReportPeriods").pqGrid(obj);
//var colM = grid.pqGrid("option", "colModel");
//grid.pqGrid("option", "colModel", colM);
//grid.pqGrid('refreshDataAndView');
});
I am following the demo exactly and I've used the developer tools in Chrome to debug. I have viewed what is being returned for 'rowData' and I can see the value in the array I want to evaluate, but it doesn't work.
Please advise.
Sincere thanks!