"Save" button and functionality

77 views
Skip to first unread message

Evgeny

unread,
Feb 20, 2012, 11:51:47 AM2/20/12
to MyTableGrid
Hi Pablo!

MyTableGrid is a good bunch of software and it fits my needs but just
one question: could you explain how to save modified data to the
database. I'm new at js and i hope that your help will help me faster
than i'll understand everything.

Thanks in advance!

Pablo Aravena

unread,
Feb 20, 2012, 12:21:22 PM2/20/12
to mytab...@googlegroups.com
Hi Evgeny

Based on the code in page
http://pabloaravena.info/mytablegrid/samples/tablegrid/sample_cars1.php

First you need a JavaScript console, provided by default in Chrome or
use FireBug plugin in FF

If you modified a row in the grid then you can type the following the
javascript console

tableGrid1.getModifiedRows()

Basically you can use that instruction for building an Ajax HTTP request in the
onSave handler. The way you implements this request depends on what
you have in the server side. For example:

onSave : function () {
var modifiedRows = tableGrid1.getModifiedRows();
var request = {};
modifiedRows.each(function(item){
var id = item.id;
request['carId'] = id;
request['manufacturer;'+id] = item.manufacturer;
request['model;'+id] = item.model;
// etc ...
});

new Ajax.Request({'your URL', parameters : request, onSuccess :
<your callback>})
}

When building that request object, notices that for each request
parameter I added the id suffix, that will help you when reading the
request values in the server side.

Hope it helps you


Have an excellent day

Pablo

> --
> You received this message because you are subscribed to the Google Groups "MyTableGrid" group.
> To post to this group, send email to mytab...@googlegroups.com.
> To unsubscribe from this group, send email to mytablegrid...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mytablegrid?hl=en.
>

Evgeny

unread,
Feb 20, 2012, 12:38:04 PM2/20/12
to MyTableGrid
Pablo,

Thanks for the reply.

Well, I saw this code so mytablegrid code doesn't impement saving to
DB, it just returns the formatted modified values and i should write
this script myself, am i right?

Regards,
Evgeny

On 20 фев, 21:21, Pablo Aravena <paraven...@gmail.com> wrote:
> Hi Evgeny
>
> Based on the code in pagehttp://pabloaravena.info/mytablegrid/samples/tablegrid/sample_cars1.php

Pablo Aravena

unread,
Feb 20, 2012, 12:50:20 PM2/20/12
to mytab...@googlegroups.com
Yes, you are right Evgeny, you have to implement the server side part,
then refresh the grid, I forgot that you have to call the refresh()
method in onSuccess handler.
Reply all
Reply to author
Forward
0 new messages