Update editable grid and save changes to db

1
0
-1

Hi,

I have populated editable grid from db.

In save button->action-> I created a boolean variable which takes boolean return value from script which contains following code:

import groovy.sql.Sql;

import java.sql.Driver; def Integer n = field_EditableGrid1.size(); def String str; def host = "localhost:3306"; def user = "root"; def pass = "root"; def schema = "test";

def sql = BonitaSql.newInstance("jdbc:mysql://$host/$schema","$user","$pass", new com.mysql.jdbc.Driver());

for (int i=0; i<n; i++) { def String s1 =field_EditableGrid1.getAt(i).get(0) println "hello world"; println s1; def query=""; query="update test.as2tpdetails set status='"+ s1 + "';" sql.execute(query); } return true;

but my database is not updating no error is shown

Regards Manoj

Comments

Submitted by manoj_5 on Sat, 01/24/2015 - 14:05

Hi,

In above I noticed that the changes made in editable grid data values are not available in the list that we are sending to update db. I mean in the for loop above there is only old copy of the data, thats why update is not working.

In output operation of grid I created a variable of list type to store editablelist data

and in action button, used script to update the code

Can you tell me how we can get updated (changed) data from editable grid and provide it to script to update DB?

Thanks Manoj

Submitted by Sean McP on Tue, 01/27/2015 - 12:44

I've just tested this and it works, I hope the output variable is a NEW or different variable and you're not trying to use the old variable (which filled in the data).

In the connector dump out the data to log and see what happens

As I say, it works for me...

regards Seán

No answers yet.
Notifications