Change only the local data for listgrid

The updateData method always tries to post data to the server. My question is if we can control this so that in cases it changes only the local data (like the clientonly ds does) and does not contacts the server. Or is that a workaround to change the local data only for listgrid. I tried setEditValues, and it seems change the UI only not the resultset behind the scene so if the record in gridlist is selected, the old data shows up in editor. Following is my code:

isc.DataSource.create({
ID:“OTT_findAll”,
title:“OTT_findAll”,
dataFormat:“json”,
dataURL:“/fast_portlets/fastservicejsservlet?Service=OTT_findAll”,
//clientOnly: true,
fields:{
offTerritoryTimeId:{name:“offTerritoryTimeId”, title:“OTT ID”, type:“float”, primaryKey:true, hidden:false, disabled:true},
offTerritoryDate:{name:“offTerritoryDate”, title:“Date”, type:“date”, length:128, required:false},
reason:{name:“reason”, title:“Reason”, length:20, required:false, hidden:false},
duration:{name:“duration”, title:“Duration”, length:50, required:false, hidden:false}
}
});

isc.RPCManager.actionURL = “/fast_portlets/fastserviceservlet”;

isc.VLayout.create({
//top:100,
//left:100,
width:600,
height:400,
minWidth: 300,
minHeight: 200,
position: “relative”,
border:“1px solid blue”,
layoutMargin:5,
canDragResize: true,
members: [
isc.ListGrid.create({
showRollOver:true,
//position:“relative”,
ID:“ottList”,
//autoDraw:true,
dataPageSize: 50,
drawAheadRatio: 4,
alternateRecordStyles:true,
dataSource: OTT_findAll,
height:“*”,
width:“600”,
//edgeSize:5,
canEdit:false,
dataPageSize: 50,
drawAheadRatio: 4,
recordDoubleClick: “recordEdit()”
})
]
});

//dojox.off.files.cache(OTT_findAll.dataURL);

ottList.fetchData();

function recordEdit(){
isc.Dialog.create({
title:‘Edit OTT’,
autoSize:true,
isModal:true,
saveData:updateRecord,
toolbarButtons:[
isc.Dialog.OK,
isc.Dialog.CANCEL
],
items:[
isc.DynamicForm.create({
ID:“OTTEditor”,
dataSource: OTT_findAll
//left:30, top:300,

        })
    ]
});
OTTEditor.editSelectedData(ottList);

}

function updateRecord(){
var values = OTTEditor.getValues();
ottList.setEditValues(ottList.getRecordIndex(ottList.getSelectedRecord()), values);
}

Hi Xiaow,

It sounds like you want to initially load some data from the server (from a DataSource), then allow modification of the data on the client but not notify the dataSource of the changes.

Probably easiest to do this by calling ‘fetchData’ directly on the dataSource, which will return an array of records, which can then be set as data on your grid via ‘setData()’.
Changes to the ListGrid’s data via editing, or via directly manipulating the data array object will then all occur locally.

If this approach won’t work for your application, perhaps you could give us a bit more detail on what your use-case is, so we can give you a more appropriate suggestion.

Thanks

Isomorphic Software

Thanks for your reply.

It seems if invoking listgrid.fetchData, the listgrid.data object is an unchangeable resultset. But if invoking datasource.fetchData, the response data is a changeable array. Interesting…

Yes - the difference is that once you call listGrid.fetchData, the ListGrid’s data object is set to a ResultSet instance. ResultSets are designed to “stay in sync” with server data - any changes to the DataSource’s underlying data will automatically be picked up by the ResultSet, and edits to the ListGrid will automatically be committed to the server.
In other words, once you call ListGrid.fetchData(), the listGrid starts to display the data on the server. Modifying the ListGrid data directly on the client at this point would be inappropriate as it would no longer be in synch with the server data.

By contrast the dataSource.fetchData method returns a simple array object - a snapshot of the current server data that matches the criteria. It’s a purely static object on the client that you can use and modify this however you like

Hope this clarifies things a little!

Isomorphic Software