I have 3 columns in a grid "time", "username" and "title":
colModel : [
{dataIndx:'time', maxWidth:48, title:lang.timeTxt, dataType:"date",
render:function(ui){
return {
text: moment(ui.cellData).format("LT"),
attr: 'title="'+moment(ui.cellData).format("LLL")+'"'
};
}
},
{dataIndx:'username', maxWidth:52, title:lang.userTxt, dataType:"stringi", filter:{crules:[{condition: 'contain'}], style:"text-align:"+dir},
render:function(ui){
return {
text: String(ui.cellData),
attr: 'title="'+String(ui.cellData).replace('"', '\"')+'"'
};
}
},
{dataIndx:'title', title:lang.descriptionTxt, dataType:"stringi", filter:{crules:[{condition: 'contain'}], style:"text-align:"+dir},
render:function(ui){
var txt = (empty(ui.rowData["qty"])?"":ui.rowData["qty"]+" x ") + ui.cellData + (empty(ui.rowData["barcode"]) ? "" : " ("+ui.rowData["barcode"]+")");
return {
text: txt,
attr: 'title="'+txt.replace('"', '\"')+'"'
};
}
}
]
I insert a new row with the following: $grid.pqGrid("addRow", {newRow:rowData, rowIndx:0});
The issue is that the fields in rowData are being removed if the field is in the colModel.
Before:
{
barcode: "2616",
box: 0,
error: true,
id: 0,
qty: 0,
time: "2023-08-06 22:06:25",
title: "<a href='/modules/stock/equipment.php?asset=816' target='_blank'>Slick Litebox (2m, LX2000) (2616)</a> is damaged",
user_id: 1,
username: "User's name"
}
After (I added a console.log(ui.rowData) in the render and the rowInit to get the data):
{
barcode: "2616",
box: 0,
error: true,
id: 0,
pq_hideOld: undefined,
pq_render: 1,
pq_ri: 0,
pq_top: undefined,
qty: 0,
user_id: 1
}
As you can see all the data is there, but the fields that match a column in the colModel have been removed. I can show you the console view to prove it. I get exactly the same with addNodes.
However it does work if I add the parameter checkEditable:false in the "addRow" options.