I am stack with a problem (which might be very simple but for some reason I just can't figure it out) regarding record drag 'n drop functionality between 2 listgrids.
I have 2 datasources for a many-to-many parent-child relation
Datasources
Then I create 2 listgrids and bind them with those datasources (following the listgrid move example code).
Listgrid "myList1" shows the children of a filtered context.
Listgrid "myList2" shows all the context records, so the user can drag 'n drop records in order to add (or remove) children.
In order to do that, I have to alter the incoming record (from myList2) like this:
a) keep the ID of the record and put it to the "context_group" attribute
b) insert the ID of the context whose the children are shown to myList1
I couldn't find a way to use the "dropValue" attribute so I tried to overload the getDropValues but I still see that the RPC sent to the server has the record from myList2 datasource intact...
What am I missing?
I have 2 datasources for a many-to-many parent-child relation
Datasources
Code:
isc.RestDataSource.create({ ID:"context", fields:{ id:{name:"id", type:"integer", primaryKey:true, hidden:true}, name:{name:"name", type:"text"}, displayname:{name:"displayname", type:"text", length:50}, type:{name:"type", type:"text", length:10}, comments:{name:"comments", type:"text", length:100}, canbedeleted:{name:"canbedeleted", type:"text", length:5} }, dataFormat:"json", dataURL:"/service.php", sendMetaData:true }) isc.RestDataSource.create({ ID:"context_group", fields:{ id:{name:"id", type:"integer", primaryKey:true, hidden:true}, context_group:{name:"context_group", type:"integer", foreignKey:"context.id", foreignKey:"context.id", optionDataSource:"context", displayField:"displayname", valueField:"id"}, context_grouped:{name:"context_grouped", type:"integer", foreignKey:"context.id", optionDataSource:"context", displayField:"displayname", valueField:"id"} }, dataFormat:"json", dataURL:"/service.php", sendMetaData:true })
Code:
isc.ListGrid.create({ autoDraw: false, autoSaveEdits:false ID:"myList1", dataSource:context_group, autoFetchData:true, canDragResize:true, canDragRecordsOut: true, canAcceptDroppedRecords: true, canReorderRecords: false, dragDataAction: "copy", // dropValue:{"id"}, getDropValues: function(record, sourceDS, targetRecord, index, sourceWidget) { if (!this.addDropValues) return; isc.logWarn("Something was dropped --- " + isc.echoAll(record)); var dstRec = {context_group: this.context_group, context_grouped: record.id}; return dstRec; }, fields:[{name:"context_grouped", align:"left"}] }), isc.VStack.create({width:32, height:74, layoutAlign:"center", membersMargin:10, members:[ isc.Img.create({src:"icons/32/arrow_right.png", width:32, height:32, click:"myList2.transferSelectedData(myList1)" }), isc.Img.create({src:"icons/32/arrow_left.png", width:32, height:32, click:"myList1.transferSelectedData(myList2)" }) ]}), isc.ListGrid.create({ ID:"myList2", dataSource:"context", fields:[ {name:"displayname"}, {name:"name"}, {name:"type"} ], autoFetchData:true, canDragResize:true, canDragRecordsOut: true, canAcceptDroppedRecords: true, dragDataAction: "copy", canReorderRecords: true }) ]})
Listgrid "myList2" shows all the context records, so the user can drag 'n drop records in order to add (or remove) children.
In order to do that, I have to alter the incoming record (from myList2) like this:
a) keep the ID of the record and put it to the "context_group" attribute
b) insert the ID of the context whose the children are shown to myList1
I couldn't find a way to use the "dropValue" attribute so I tried to overload the getDropValues but I still see that the RPC sent to the server has the record from myList2 datasource intact...
What am I missing?
Comment