Drag and Drop Grid

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Drag and Drop Grid

Post by psurrena »

I'm looking to build a program that lets a user drag and drop icons onto a grid. The icons represent people and the grid is career related. I'm thinking the "people" would be pulled from my existing database. My big question is, in PHP is there a way to save this information? Would it be better done in Flash?

What would need to be saved is, what icon is in what location on the grid. The location could just be div boxes.

Could this be written back to a database or better stored in XML? Can this even be done??

My goal is people could create their own layouts and then go back to them or show them to others.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Drag and Drop Grid

Post by pickle »

The jQuery UI library was just released - included in it is a way to make anything draggable, but force it to move along a grid - you might be able to implement that some way.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Re: Drag and Drop Grid

Post by psurrena »

Great, I'll check it out. I guess the big issue is grabbing to coordinates. Anyone know if that's possible?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Drag and Drop Grid

Post by pickle »

Trying not to be a jQuery whore here, but it's what I know...

Part of the jQuery UI library is dedicated to droppables. It'd be pretty straightforward (once one gets their head around it), to set up a grid of divs with ids denoting their grid location (1-1, 1-2, 1-3, 2-1, 2-2, etc). When an item is dropped on a div, you then know which item is in which location. You can then use AJAX to store that location, or use JS to store that information in hidden form fields, then post a form later, or some other solution I haven't thought of.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Re: Drag and Drop Grid

Post by psurrena »

That's perfect, thanks so much!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Drag and Drop Grid

Post by Christopher »

You might also look at the Ext library. It sits on top of lower level Javascript libraries and provides a lot of higher level functionality.
(#10850)
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Re: Drag and Drop Grid

Post by arjan.top »

unless your app is GPL stay away from ext (you must pay for commercial use)
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Re: Drag and Drop Grid

Post by psurrena »

I will play with jQuery, it seems within my (mental) grasp right now.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Drag and Drop Grid

Post by Kieran Huggins »

don't be afraid to use tables when they're appropriate!
Post Reply