Author Topic: BUG: addRow is removing the columns from the data passed.  (Read 305 times)

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 131
    • View Profile
BUG: addRow is removing the columns from the data passed.
« on: August 07, 2023, 03:56:26 am »
I have 3 columns in a grid "time", "username" and "title":

Code: [Select]
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:
Code: [Select]
$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:
Code: [Select]
{
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):
Code: [Select]
{
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.



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: BUG: addRow is removing the columns from the data passed.
« Reply #1 on: August 07, 2023, 06:47:52 am »
Cell values are not added if the cells are uneditable.

checkEditable: false parameter has to be passed to add or update values of uneditable cells.