Drag and Drop Grid
Moderator: General Moderators
Drag and Drop Grid
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.
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.
Re: Drag and Drop Grid
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.
Re: Drag and Drop Grid
Great, I'll check it out. I guess the big issue is grabbing to coordinates. Anyone know if that's possible?
Re: Drag and Drop Grid
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.
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.
Re: Drag and Drop Grid
That's perfect, thanks so much!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Drag and Drop Grid
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)
Re: Drag and Drop Grid
unless your app is GPL stay away from ext (you must pay for commercial use)
Re: Drag and Drop Grid
I will play with jQuery, it seems within my (mental) grasp right now.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: Drag and Drop Grid
don't be afraid to use tables when they're appropriate!