PDA

View Full Version : editable grid(get data from sql not from xml?)



david83
16 Jan 2007, 8:00 AM
hey guys!
i want to create editable grid like this url:
http://www.jackslocum.com/blog/2006/09/10/adding-built-in-editing-support-to-the-yahoo-ui-extensions-grid/

but i want to get data from mysql not from xml. and i want to save this changed values.
http://www.jackslocum.com/blog/images/error-example.gif
for example when change this date from 19/06/06 to 12/01/05 i want to write this value to mysql. and when i reload the page next time should read this value from sql and date should be 12/01/05...
can you help me? realy i don't understand this javascript very well

tryanDLS
16 Jan 2007, 8:04 AM
Please don't create multiple threads with the same question. I deleted your previous post titled 'c' and copied my response below.

You need to retrieve the data from SQL and build an XML doc or a JSON object and pass that to the client. You have to manage the updates yourself. If you use XML, the grid will keep the underlying XML doc in sync as you edit the grid, however you still have to pass the xml back to the server and determine what has changed and how to update SQL.

You need to learn javascript before attempting this. This is a complex structure and you're not going to be able to just drop code into your page and make it work if you can't understand the javascript.

david83
16 Jan 2007, 11:25 PM
this was my first question on this forum. i didn't create post titled 'c'.
anyway is there a example with editable grid which geting datas from sql or oracle like this
http://www.constantdns.com/lgplus/lgplus.zip

Animal
17 Jan 2007, 1:14 AM
The examples posted in Jack's blog will get you started if you read them.

http://www.jackslocum.com/blog/

How the data gets into your grid is up to you. YOU provide a DataModel. The Grid asks the DataModel for the data whenever it needs to, and informs the DataModel of changes to the data. You will add your code to the DataModel to get data from the server, and update if necessary.

If you are using Java, I'd advise you to check out DWR as a means of sending data back and forth.

http://getahead.ltd.uk/dwr/

Or you could use the provided XMLDataModel, and write a servlet/PHP script or whatever that provides an XML document containing the requested data.

lost_in_eternity
9 Feb 2007, 11:49 PM
yea i want to know too. how can we get data from sql not from xml. Is there any way to not use the provided XMLDataModel

Animal
10 Feb 2007, 12:33 AM
You do know that in the browser you are completely seperate from your database don't you? There's no connection at all.

It is up to you to provide a mechanism on your server that will perform the SQL query, and then provide the data to the browser. You write a servlet or PHP script that accepts parameters and performs the SQL query, and returns data.

Having acknowledged that basic truth, then the question is "what format do I provide this data to the browser in?".

Well here is where yui-ext does a LOT for you.

Your server PHP script/servlet/whatever sends the dataset as XML and the provided XMLDataModel does all the plumbing for you

lost_in_eternity
10 Feb 2007, 2:22 AM
and is there sample with XMLDataModel?

Animal
10 Feb 2007, 2:27 AM
Yes there is.

lost_in_eternity
10 Feb 2007, 2:49 AM
can you give me directly links please?

tryanDLS
10 Feb 2007, 7:46 AM
Did you trying looking at the stuff you downloaded? There's an entire folder of examples.

Animal
10 Feb 2007, 8:21 AM
It's as if you have no interest at all. I've scoured every blog entry Jack has made to discover the capabilities of this library (not that I'm an expert on all areas of it by any means). I've scoured the manuals, read source code. Put some effort in!

Information to do what you want is readily available linked from the yui-ext home page

Here: http://www.jackslocum.com/blog/2006/08/31/a-grid-component-for-yahoo-ui-part-2/

And linked from the extremely Fine Manual

Here: http://www.yui-ext.com/deploy/yui-ext/examples/grid/xml-grid.html