Best way to save drag and drop layout

I have seen this question several times, but mostly it concerns individual objects and cookies. I am creating an application with the ability to drag a toolbar (very similar to what you see in Visual Studio - i.e. dragging and dropping objects into a form, giving them a name, etc.). Therefore, there can be many objects in a deleteable area, including nested droppables.

Any opinions on what is the best way to save a SQL Server database and then reload such a complex layout? Objects should be loaded and displayed exactly as they were saved. This will be done by ajax, but beyond that I am not sure what is best to continue. Also, any examples that could point me in the right direction would be great.

Significant duty.

+6
javascript jquery sql-server
source share
2 answers

You can serialize data via XML or JSON and save the serialized string in the database. This would simplify your database and web services infrastructure than having to keep each control separate, but for more parsing on the JS side, more parsing will be needed, but since your application sounds like JS-heavy, I guess it should not be problem for you.

var state = { textbox1:{ x:100, y:200, width:20, height:10, defaultValue:'Hello world!' }, button1:{ x:150, y:200, width:20, height:10, text:'Push me!' } } var serialized = JSON.stringify(state); yourService.SaveSate(serialized) //made this object up to mock your web service 

JSON.stringify only works in modern browsers, but there are many alternatives if you focus on old things.

+2
source share

If you are trying to represent a hierarchy in a relational database, there are two methods that I have seen: A list of children list model and a Nested collection model .

Here's a link to a good description of how using MySQL: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

Depending on the method you choose, what you transfer to your server will be different.

Perhaps also see this question: Saving a folder hierarchy in a relational database

+1
source share

All Articles