PDA

View Full Version : Form auto values via Json



sstratton
11 Sep 2008, 4:28 PM
I have a grid and a form window on a page, currently the form window works great for adding new items to the datasource (mysql) however, I need to pull a row from mysql and prepopulate the form should a row be selected (and a button pressed) anyways I understand how to get the id from the grid, but what I'm having a hard time with is prepoluating the values if someone cares to enlighten me on that. I thought about the grid to form demo here but my problem is there are several fields that will never show up in the grid so.

Thanks in advance.

catacaustic
11 Sep 2008, 10:23 PM
If you're taking the values from the selected row in the grid, something like...


var rec = grid.getSelectionModel ().getSelected ();

field1.setValue (rec.field1);
field2.setValue (rec.field2);
etc...I haven't tested that, but that's how I've done things in the past, and it works pretty easily.

sstratton
12 Sep 2008, 6:06 AM
Unfortunately the grid only contains half the values of the actual datasource that I'll need inside the form. For example it wont contain timeclock information (this is for an employee management setup) but that has to be set in the creation and has to be editable in /reset, would it be easier to pull those into the data store for the grid and not map them to the columns (not preferable because a lot of this is also based on permissions) ?

devnull
12 Sep 2008, 6:38 AM
Given that you said you have access to an id field from the grid, use a form.LOAD action to request the row from the server and poulate the form. This is well documented in the API docs, but if you have specific implementation quests do please post back here.