Im having a grid to populate customers table from database.
I want to insert new records to the table using a form, refresh grid and the new row (with all the data inserted) to be selected in the grid.
The addRow() is been made by the following function
function addRow() {
var newID = grid.uid();
grid.addRow(newID, "", grid.getRowsNum());
grid.selectRow(grid.getRowIndex(newID), false, true, true);
userForm = layout.cells('b').attachForm(formData);
userForm.loadStruct('common/forms.inc.php');
dp = new dataProcessor('common/dataCustomers.php');
dp.init(userForm); //link grid to dataprocessor
userForm.reset();
}
I got the update button into a toolbar attached to the Form
formToolbar.attachEvent('onClick', function (btn) {
if (btn == 'update') {
dp.sendData();
}
reloadGrid();
});
And the code for reloading grid
function reloadGrid() {
layout.progressOn();
grid.clearAndLoad('common/getCustomers.php');
layout.progressOff();
}
The problem is that i cant think any way or find any help on documentation to fix my problem. I want to change the reload code in order to handle a big amount of records so the refresh should be fast and the selection of the new row in grid to be automatic after the insert.
Any suggestions ?