gerardo.gomez wrote:Hi!
You could do it storing data what you need (the pk in your case or the whole record) in event.data when dragging on your record. Later, in onDrop event, you can retrieve your data from event.data
This strategy is used in Servoy DnD sample solution (it's used to perform multiselection on dragging) and is what we are doing.
This is the code used in Servoy DnD sample solution (in this case, the whole selected record/s is/are stored in event.data):
- Code: Select all
function onDrag(event) {
if(!event.getSource()){
return DRAGNDROP.NONE;
}
var data = [];
var selection = foundset.getSelectedIndexes();
for(i in selection){
data.push(foundset.getRecord(selection[i]));
}
event.data = data;
/* Returning both Copy & Move: the code in the onDrop method on the Order_Details form will perform a copy regardless,
* but users do not know that normally, to perform a Copy action you need to use the Control modifier
*/
return DRAGNDROP.COPY|DRAGNDROP.MOVE;
}
- Code: Select all
function onDrop(event) {
//Get the Product record objects (which were set in the onDrag method on the product_list form) from the event.data property of the event and process them
for(i in event.data){
var record = event.data[i];
// Do what you want...
I hope this helps!
Thanks Gerardo but I think you're misunderstanding the problem.
There's no problem dragging the data, pks, whatever.
The problem is when I drop on another table view and it's impossible to figure out which record I'm on.
Say, we have two table views like below. The first one is a list of assignments, the other is a list of employees.
I'm dragging an assignment and drop it on an employee (to assign it to employee).
If I drag 'Assignment 1 from the first table I sure can get the whole record data and it's good.
But when I drop it on the employee table then the problem comes up.
If I'm dropping on the employee name and there are no duplicate names in the employee table then I can get the employee name from the data attribute of onDrop event.
But if I'm dropping on the 'city' column (and I have many-many columns in the employee table) then I'm in trouble because knowing that I dropped on 'Sydney' won't give me any chance to find out what the employee id is!
The target record is not becoming selected when I drop on it, so there's no way to figure out the target record in table view (no obvious way to me, that's why I'm asking - perhaps I'm overlooking something).
---------------------------
| Assignment 1 |
---------------------------
| Assignment 2 |
---------------------------
| Assignment 3 |
---------------------------
------------------------------
| John Smith | Sydney |
------------------------------
| Ben Austen | Brisbane |
------------------------------
| Laura Singh| Sydney |
------------------------------