drag and drop solution

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Re: drag and drop solution

Postby lesouef » Mon Feb 08, 2010 1:33 pm

easy to isolate for the browser suite, remove it temp.
fyi, even if it does not fix it, I made my tests using the smart client, also started from the developer, and ondrop gets triggered on records.
my current env was xp + 5.0.1.
I am now using 5.1rc2 where ondrop does not work at all.
should be fixed for 5.1 final, Servoy said...
Soyons patients...
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby rgansevles » Thu Feb 11, 2010 12:10 pm

lesouef wrote:I am now using 5.1rc2 where ondrop does not work at all.


lesouef,

Can you try this with 5.1 rc3?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1929
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: drag and drop solution

Postby lesouef » Thu Feb 11, 2010 12:43 pm

I am using rc3 now, still the same, smart client drops nothing, not even on records like the original release.
web client mode: all ok.
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby ROCLASI » Thu Feb 11, 2010 1:18 pm

I am using 5.1rc3 and drag & drop works fine for me in the smart client.
I am using it to populate table views.

Are you using return DRAGNDROP.COPY or return DRAGNDROP.MOVE in your onDrag method ?
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: drag and drop solution

Postby rgansevles » Thu Feb 11, 2010 2:12 pm

lesouef wrote:I am using rc3 now, still the same, smart client drops nothing, not even on records like the original release.
web client mode: all ok.

Can you create a small sample and attach this to a case in our support system?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1929
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: drag and drop solution

Postby lesouef » Thu Feb 11, 2010 2:42 pm

Robert,
answer is no. I don't even know what it does. I am still looking for the doc, and even a working example, and I am not the only one obviously, viewtopic.php?f=22&t=13507
the weird thing is that it works in web mode, but this maybe a lucky side effect.
there maybe an explanation in the wiki, but no way to access that for me (account created and confirmed but never worked...) and no way to re-create one.

Rob,
I could, I am sure you'll locate the error instantly if you confirm that it works, but I'd rather understand the beast myself.
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby ROCLASI » Thu Feb 11, 2010 3:25 pm

lesouef wrote:Robert,
answer is no. I don't even know what it does.

Then there is your issue.
The onDrag needs to allow the drag to happen. You accomplish this by returning either one of those constants.
When you return nothing or return DRAGNDROP.NONE then the drag won't happen and therefor the onDragOver will never trigger.
In the onDragOver you have to allow the Drop by returning true or false, true means you will allow the drop and onDrop will trigger.
So it's sort of a cascading approach. If you disallow it somewhere in the chain the rest will simply not trigger.

lesouef wrote:the weird thing is that it works in web mode, but this maybe a lucky side effect.

I think so too.

lesouef wrote:there maybe an explanation in the wiki, but no way to access that for me (account created and confirmed but never worked...) and no way to re-create one.

Just send an email to Servoy, they will fix/reset it for you.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: drag and drop solution

Postby lesouef » Thu Feb 11, 2010 6:48 pm

DRAGNDROP is true after startDrag, selectex indexes are correct (output to console).
then I drag over the destination table, the dragOver is not triggered... what can block this event?
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby ROCLASI » Thu Feb 11, 2010 8:44 pm

lesouef wrote:DRAGNDROP is true after startDrag

Not sure what you mean by that. DRAGNDROP holds 3 possible constants that you can use.
Code: Select all
DRAGNDROP.NONE
DRAGNDROP.COPY
DRAGNDROP.MOVE

See the Application > Constants > DRAGNDROP node in the Solution Explorer

You use this constant as a return value in the startDrag event.
Code: Select all
return DRAGNDROP.MOVE

If you don't the dragOver will never trigger.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: drag and drop solution

Postby lesouef » Thu Feb 11, 2010 8:50 pm

A bit better using DRAGNDROP.MOVE (what the hell is the difference, copy returns 1, move returns 2...)
I now get the "forbidden drag" sign instead of nothing and the onDragOver is triggered, but that's all, no way to drop. I am obviously missing a step...
Just checked the wiki (I was mislead by some wrong links you can find in some places...), there is no real explanation, 3 times the same startDrag example...
Probably why I already gave up on Servoy 2 years ago... How did you find your way?
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby lesouef » Thu Feb 11, 2010 8:53 pm

our posts got crossed, but actually, my answer is the same...
off for dinner, getting kind of fed up...
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby ROCLASI » Thu Feb 11, 2010 10:06 pm

Hi Lesouf,

Can you show me the code of your startDrag and onDragOver methods ?
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: drag and drop solution

Postby lesouef » Fri Feb 12, 2010 1:50 pm

// attached to source table
function startDrag(event)
{ var data = [];
var selection = foundset.getSelectedIndexes();
for(i in selection)
{ application.output("id selected="+selection[i]); // to check
data.push(foundset.getRecord(selection[i]));
}
event.data = data ;
return DRAGNDROP.MOVE;
}

//attached to dest table
function onDragOver(event)
{ var source = event.getSource();
if(source && event.data)
{ return DRAGNDROP.COPY;
}
}

function onDrop(event)
{ application.output("drop seen");
var $order_id = forms.main.orderid ;
// Check the event object for multiple product records
for(i in event.data)
{ var record = event.data[i]; //application.output("search_r="+record.productname);
if (foundset.getSize()>0) // Check if product already in order
{ var fs = foundset.duplicateFoundSet();
if(fs.find())
{ fs.productid = record.productid;
if(fs.search()) // product exists in order, increment qty
{ fs.getRecord(fs.getSelectedIndex()).quantity += 1;
}
else if(foundset.newRecord()) // product did NOT exist, add a new record
{ orderid = $order_id ;
unitprice = 99 ;
productid = record.productid;
unitprice = record.unitprice;
quantity = 1;
discount = 0.0;
}
}
}
else //add new record not really smart but did nto spend time to clean this
{ foundset.newRecord();
orderid = $order_id ;
unitprice = 99 ;
productid = record.productid;
unitprice = record.unitprice;
quantity = 1;
discount = 0.0;
}
}
}

thx for help, but I am a bit fed up to bother you (other dev people) for the lack of proper ref for this new feature...
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: drag and drop solution

Postby ROCLASI » Fri Feb 12, 2010 2:14 pm

Doing a quick scan over your code I believe the problem lies in this method:
Code: Select all
function onDragOver(event) {
    var source = event.getSource();
    if(source && event.data) {
        return DRAGNDROP.COPY;
    }
}


You should use return true if you want to accept a drop on this element. False if you don't.
Also I believe the getSource will give the source object from the draggedover object. Not from the dragged object.
Anyway, the following code should work.
Code: Select all
function onDragOver(event) {
    var source = event.getSource();
    if(source && event.data) {
        return true;
    } else {
        return false;
    }
}


lesouef wrote:thx for help, but I am a bit fed up to bother you (other dev people) for the lack of proper ref for this new feature...

I understand Paul Bakker is working hard on this (on the wiki). It seems they like to put it out when it's all done, instead of releasing smaller parts of it.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: drag and drop solution

Postby pbakker » Fri Feb 12, 2010 3:17 pm

I understand Paul Bakker is working hard on this (on the wiki)


Indeed, we are working hard on this and we will release the separate bits when done, just like we have done so far.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

PreviousNext

Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 8 guests

cron