row.update() doesn't seem to update child/sub values
See original GitHub issueI think I have found a small(ish) bug to do with how row.update(JSON) doesn’t update children/sub values.
I’m grabbing (quite happily via AJAX) a JSON in the style of:
[{"ID":1,
"clientID":89,
"client": {
"ID":89,
"clientName":"ABC (Test Client)",
"clientAddress":null
},
"jobName":"Test Joby",
"jobAddress":"Example\r\ny",
"jobDetails":"etc etc etc"
},
{"ID":2,
"clientID":89,
"client": {
"ID":89,
"clientName":"ABC (Test Client)",
"clientAddress":null
},
"jobName":"This is test",
"jobAddress":"123 Fake Street",
"jobDetails":"etc etc etc"
},
{"ID":3,
"clientID":89,
"client": {
"ID":89,
"clientName":"ABC (Test Client)",
"clientAddress":null
},
"jobName":"Is ABC (89) but to change",
"jobAddress":"Please Enter Job Address..",
"jobDetails":"etc etc etc"
}]
Which is JSON serialized from two objects classes in PHP without any issues. Initial load is perfect (and any manual refresh with table.replaceData(‘AJAX.php’) calls etc). But when I use row.update(myXMLHttpRequest.responseText) only the top level (ID, jobName, jobAddress, & jobDetails) update in the grid leaving the child ones unchanged (client.ID, client.clientName, & client.clientAddress) displaying the old values.
myXMLHttpRequest.responseText
being something akin to:
{"ID":3,
"clientID":81,
"client": {
"ID":81,
"clientName":"Test Client",
"clientAddress":null
},
"jobName":"Was ABC (89) now another",
"jobAddress":"Please Enter Job Address..",
"jobDetails":"etc etc etc"
}
I know the underlying row object has replaced the values with the new one (I’ve console logged the row and shows correctly updated JSON including client sub JSON) but not updated the cells that display that data. If I resort the columns (any column) it does update.
Using Tabulator v4.2.7 (latest)
Table columns (abridged for clarity)
{title:"ID", field:"ID", visible:false},
{title:"Job Name", field:"jobName", editor:"input", validator:["required", "maxLength:32"]},
{title:"Client", field:"client.clientName"},
{title:"ClientID", field:"clientID", visible:true},
{title:"Client.ID", field:"client.ID", visible:true},
{title:"Job Address", field:"jobAddress", editor:"textarea", validator:"required", formatter:"textarea"},
In screenshot the third entry’s client has been changed from “ABC (Test Cient)” to “Test Client”. While the clientID cell has updated the client.clientName and client.ID cells haven’t - despite the JSON having changed.
Tested on
- OS: Win 10
- Browser: Chrome
- Version: 74
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Sounds like a good idea to me. That would be an Oli answer though.
What happens if you do a table.redraw() or table.redraw(true) after the row.update()?