SmartClient: v9.0p_2013-08-19 (2013-08-19)
I am trying to update the data in a ListGrid that uses a clientOnly DataSource, but when I call the ListGrid.updateData(updatedRecord), a warning message is being shown: "clientOnly update operation failed: unable to find matching record. Did you supply all primaryKeys?".
As I could see, I'm supplying all the primaryKeys. Is there any additional step I need to do for that to work?
The code below tries to update a record from the ListGrid after 3 seconds.
I am trying to update the data in a ListGrid that uses a clientOnly DataSource, but when I call the ListGrid.updateData(updatedRecord), a warning message is being shown: "clientOnly update operation failed: unable to find matching record. Did you supply all primaryKeys?".
As I could see, I'm supplying all the primaryKeys. Is there any additional step I need to do for that to work?
The code below tries to update a record from the ListGrid after 3 seconds.
Code:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> <title>Test Update client only DataSource</title> <script>var isomorphicDir = "isomorphic/";</script> <script src="isomorphic/system/modules/ISC_Core.js"></script> <script src="isomorphic/system/modules/ISC_Foundation.js"></script> <script src="isomorphic/system/modules/ISC_Containers.js"></script> <script src="isomorphic/system/modules/ISC_Grids.js"></script> <script src="isomorphic/system/modules/ISC_Forms.js"></script> <script src="isomorphic/system/modules/ISC_DataBinding.js"></script> <script src="isomorphic/skins/Enterprise/load_skin.js"></script> <script> (function(root) { var test = root.test = {}; test.createListGrid = function() { isc.ListGrid.create({ ID: "listGrid", width: 500, height: 300, dataSource: test.createDataSource() }); }; test.fields = [ { name : "id", title : "ID", type : "integer", hidden: true, primaryKey: true }, { name : "itemName", title : "Item", type : "text" }, { name : "unitCost", title : "Unit Cost", type : "integer" } ]; test.createDataSource = function() { var dataSource = test.dataSource = isc.DataSource.create({ ID: "listGridDataSource", clientOnly: true, fields: test.fields }); return dataSource; }; test.init = function() { test.count = 30; test.unitCost = 0; test.createListGrid(); listGrid.setData(test.generateData(test.count, test.unitCost)); setTimeout(test.updateData, 3000); }; test.generateData = function(count, unitCost) { var data = []; var item; for (var i = 0; i < count; i++) { item = { itemName: "itemName" + (i < 10 ? "0" : "") + i, unitCost: unitCost, id: 100 + i }; data[data.length] = item; } return data; }; test.updateData = function() { var updatedRecord = isc.addProperties( listGrid.getRecord(0), {unitCost: 100} ); listGrid.updateData(updatedRecord); }; })(this); </script> </head> <body onload="test.init();"> </body> </html>
Comment