Problem getting the event source properties onDrop

Hi All!

I am running an onDrop method in one of my table view forms and cannot access the properties of the object I’m dropping on.
event.getSource() gets me the label I’m dropping on and event.getSource().getDataProviderID() gets the right dataprovider id behind it.
But I can’t get the value of that dataprovider though it does show up in the event properties. What would be the right method for that?

That’s what I have got if I’m dropping on a label and on a field with the same dataprovider (I’ve tried using both a label and a field just in case):
[attachment=1]1.jpg[/attachment]
[attachment=0]2.jpg[/attachment]

What I need to get is the “BookMark1” string which is the dataprovider value of the target label/field.

Generally, it would be great to find out the index or the primary id of the row I’m dropping on in a table view.
Otherwise, how do I figure out what record is selected?

Please help! :?:

Anyone? No one? :?:

If you have the dataproviderid, you can use controller.getDataProviderValue(dataproviderid) to get it’s value.

Paul

pbakker:
If you have the dataproviderid, you can use controller.getDataProviderValue(dataproviderid) to get it’s value.

Paul

Yes, but it’s not the primary key of the record.
Say, we have a list of customers and the grid would have a customer name, customer address fields, etc.
If I drop on a column with the city (as part of the customer address) it won’t give me any useful information as the city would be the same for many customers.
How do I know on which one I dropped?

Cheers,
Maria

P.S. Either I’m not getting it or it’s strange that no one has run into this problem before :?

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):

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;
}
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!

gerardo.gomez:
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):

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;

}






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 |

Unfortunately, determining the exact record in TableViews on which the drop took place is currently not possible.

It will be made possible in a future version

Paul

pbakker:
Unfortunately, determining the exact record in TableViews on which the drop took place is currently not possible.

It will be made possible in a future version

Paul

Thanks Paul.
It’s good to know I’m not making things up :)

Cheers,
Maria