Hi,
I'm using SmartClient_v82p_2012-09-11_LGPL and copied a code from smartclient wiki to drag/drop order listgrid rows.
(http://wiki.smartclient.com/display/...rsistent+order)
My problem is that is my Datasource is defined with postParams
Everything is fine with all request send with post method except the row ordering queue.
The queue make a request to "/data?id=2&userOrder=1&_operationType=update&_oldValues=%7B%22userOrder%22%3A%222%22%7D&_componentId=refsList&_dataSource=ds_refs&isc_metaDataPrefix=_&isc_dataFormat=json"
not just simple to "/data"
i wanted to make a request with post params only.
Datasource Code:
recordDrop Code:
Thanks
I'm using SmartClient_v82p_2012-09-11_LGPL and copied a code from smartclient wiki to drag/drop order listgrid rows.
(http://wiki.smartclient.com/display/...rsistent+order)
My problem is that is my Datasource is defined with postParams
Everything is fine with all request send with post method except the row ordering queue.
The queue make a request to "/data?id=2&userOrder=1&_operationType=update&_oldValues=%7B%22userOrder%22%3A%222%22%7D&_componentId=refsList&_dataSource=ds_refs&isc_metaDataPrefix=_&isc_dataFormat=json"
not just simple to "/data"
i wanted to make a request with post params only.
Datasource Code:
Code:
isc.RestDataSource.create({
ID: 'ds_refs',
operationBindings: [{operationType:"fetch", dataProtocol:"postParams"},{operationType:"add", dataProtocol:"postParams"},{operationType:"update", dataProtocol:"postParams"},{operationType:"remove", dataProtocol:"postParams"}],
dataFormat: 'json',
fetchDataURL: '/data',
addDataURL: '/data',
removeDataURL: '/data',
updateDataURL: '/data',
fields: [
{name: 'id', primaryKey: true},
{name: 'name'},
{name: 'photo'},
{name: 'description'},
{name: 'category'},
{name: 'public'},
{name: 'userOrder'}
],
});
Code:
recordDrop : function (dropRecords, targetRecord, targetIndex, sourceWidget) {
if (this == sourceWidget && dropRecords.length != 0) {
var data = this.data;
var dropRecordIndices = dropRecords.map(function (record) {
return data.findIndex("id", record.id);
});
var indicesMin = Math.min(dropRecordIndices.min(), targetIndex);
var indicesMax = Math.max(dropRecordIndices.max(), targetIndex - 1);
var startedQueue = !isc.RPCManager.startQueue();
var ds = isc.DS.get(this.dataSource);
var request = {
operation:this.updateOperation,
application:this.application,
willHandleError:true,
oldValues:{ userOrder:0 },
componentId:this.ID
};
// Update the 'userOrder' fields for all records at indices [indicesMin, indicesMax].
var userOrders = new Array(indicesMax + 1 - indicesMin);
var i;
for (i = indicesMin; i <= indicesMax; ++i) {
var record = data.get(i);
userOrders[i - indicesMin] = record.userOrder;
}
var numDropRecordsAfterOrAtTargetIndex = 0;
for (i = indicesMax; i >= targetIndex; --i) {
if (dropRecordIndices.contains(i)) {
++numDropRecordsAfterOrAtTargetIndex;
}
}
var numDropRecordsBeforeTargetIndex = dropRecords.length - numDropRecordsAfterOrAtTargetIndex;
var j = 0; // how many drop records have been encountered so far.
for (i = indicesMin; i < targetIndex; ++i) {
var record = data.get(i);
request.oldValues.userOrder = record.userOrder;
request._originalRecord = isc.shallowClone(record);
var updates = ds.filterPrimaryKeyFields(record);
if (dropRecordIndices.contains(i)) {
updates.userOrder = record.userOrder = userOrders[targetIndex - numDropRecordsBeforeTargetIndex + j - indicesMin];
++j;
} else {
updates.userOrder = record.userOrder = userOrders[i - j - indicesMin];
}
ds.updateData(updates, null, request);
}
j = 0;
for (i = indicesMax; i >= targetIndex; --i) {
var record = data.get(i);
request.oldValues.userOrder = record.userOrder;
request._originalRecord = isc.shallowClone(record);
var updates = ds.filterPrimaryKeyFields(record);
if (dropRecordIndices.contains(i)) {
updates.userOrder = record.userOrder = userOrders[targetIndex + numDropRecordsAfterOrAtTargetIndex - 1 - j - indicesMin];
++j;
} else {
updates.userOrder = record.userOrder = userOrders[i + j - indicesMin];
}
ds.updateData(updates, null, request);
}
// If we're queuing, send the queue now.
if (startedQueue) {
isc.RPCManager.sendQueue(null, null, null, true);
}
}
// Call the super implementation of recordDrop() to update the order of rows in the ListGrid.
this.Super("recordDrop", arguments);
}
Comment