Saturday, October 11, 2008

Big news for the incoming P4A 3.2

Yes, big news for the incoming P4A 3.2

I've just finished to commit the first beta release of a new widget: the p4a_grid.
What is it? It's simply an editable table. This widget has been for a lot of time a highly requested feature so now I'm really happy to have it :) There's a lot of work to be done to have the perfect widget, for example to add checkbox cells and combo box cells, but now it already does a good job.

Using the p4a_grid is similar to using the p4a_table:

$this->build("p4a_grid", "grid")
->setWidth(600)
->setSource($this->source)
->setVisibleCols(array("product_id", "model", "date_arrival", "category", "brand"));

Now you have two options:

1) Using the "autosave" method to save automatically the changed values to database

$this->grid->autosave();

2) Intercepting the onChange event if you need to add more complex business logic:

$this->intercept($this->grid,'onChange','myhandler');
...
function myhandler($obj,$params){
/*
$params[0] -> the primary key value
$params[1] -> the column name
$params[2] -> the formatted new value
$params[3] -> the unformatted new value
*/
...
}

If you want to try it checkout it from svn and please give me your feedback :)