Is it possible to save data back? Carlos?
debdebe
April 7,
You need to use (or call) some "serve side script code" like PHP,CGI or ASP (with, or without XLM) to perform POST operation to a server DB.
could be done with ADO/ODBC-connection (or open/close a DB with CGI commands).
Then, (after update the DB, with any of above), the server generates a new "csv/xlm" file that reload the grid data - "Get".
I know, it sounds easy for (local test or single user), but in a multi-user environment (and keeping in mind that we are off-line) it is a "must" to control a lot of updating situations.
like:
- try to modify a record that not longer exist into D.B. (deleted e few seconds ago - but you can see it )
- updating a (just updated record)
- append (unique key) duplicates ........ etc
(so maybe need to generate a possible errors "at server" and "lock" the grid with some "last changes unsuccesfull- please reload" --message
HTH
Carlos
April 7,
Thanks carlos. But you said that: "You need to use (or call) some "serve side script code" like PHP,CGI or ASP (with, or without XLM) to perform POST operation to a server DB"
I know PHP very well. But the point is how can we transfer data in javascript array, to the server side script?
Normally we have forms and We can post data with submitting forms. For example If we have a form element named "tel" (..input type=text name=tel ..), we can get it as variable like "$tel" at the server side script(PHP).
How can we do it with these grids. How can we submit grid values to the server side script?
debdebe
April 7,
In very simplistic case you can have hidden textarea element in your form:
<textarea id="myId" name="myArg"></textarea>
and use javascript code like this one:
document.getElementById("myId").value = myData.join("\n");
and then submit form to the server.
This simple join("\n") call will insert line break between rows and comma between cells, but in real life you probably need more complex formatting to escape commas inside your cell data etc.
Alex (ActiveWidgets)
April 7,
You could use the $_GET[''] and it should work. Ex.
header('Location: page.php?myVar=something&myOtherVar=something');
and then in page.php
if(isset($_GET['myVar']))
{
do this
}
olman
April 7,
Are there any solution which developed before?
I can understand Alex'es answer but not Olmans answer. How can we pass the data to the server side script page? I mean; what will javascript when user pres the submit button?
debdebe
April 7,
The script will create XMLHTTPRequest object, calls open method with âPOSTâ, URL as arguments, calls send(data) method where data is âapplication/x-www-form-urlencodedâ string, collection of parameters (this is where you should put your data which you normally send through HTML FORM). Then script waits for server reply â you can detect this either with callback or by polling readyState property â and repaints parts of your page. Your full page is not send back and forth â the script does everything in the background.
ActiveWidgets has a class which does all that and is used as a base for CSV and XML retrieval (Active.HTTP.Request). But you can also post data back with this class, not only retrieve.
Here is a nice article which explains it better than I do:
http://www.adaptivepath.com/publications/essays/archives/000385.php
Alex (ActiveWidgets)
April 8,
Alex - I've read about AJAX so much I want to vomit... it still doesn't get us anywhere with this thread. What I would like to see is a solid concreate example of how to set up an ActiveWidget grid that pulls from a database with editable cells that has the ability to be saved back to a database. I use ColdFusion for example, and while I have easily written a page using your ActiveWidget code to pull data from a database and populate a grid - there seems to be zero examples of how one would go about updating a DB using your javascript code. I keep reading about how XMLHTTPRequest can be used to do this - but I have never seen code showing exactly how.
I think for your code to be useful to web developers around the globe, an example of this would be needed. This thread seems like the perfect place.
Mike
August 11,
I certainly wouldn't call myself a JavaScript expert, but first, I'm assuming there must be some function that can even turn the cells into "input" elements to begin with. Making the further assumption that the script also has some "on change" event that can further examine the changes as well as post any data back to the server, I would think it is a somewhat trivial task. No?
Of course, nobody wants to re-invent the wheel. I'd love to see some examples of code that can do this so I can run with it for my application!
Ed
August 11,