Re: Re: DB_DataObject and Structures_DataGrid integration

From: Date: Thu, 12 Aug 2004 17:34:02 +0000
Subject: Re: Re: DB_DataObject and Structures_DataGrid integration
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-32594@lists.php.net to get a copy of this message
Andrew Nagy wrote: > Olivier Guilyardi wrote: > >> Hi, >> >> I want to bind Structures_DataGrid to DB_DataObject in a more integrated >> manner than Structures_DataGrid_Record_DataObject. > > > Here is something, while researching how microsoft does the DG, i found > that you might find interesting. > > > http://msdn.microsoft.com/netframework/default.aspx?pull=/msdnmag/issues/04/08/gridview/default.aspx > > > > It is a new type of DataGrid they are calling DataView in which it is an > all in one datagrid and database abstraction layer. > GridView, not DataView. Please be precise when it comes to .NET and its kazilion of components ;) Actually, these new components they name Data Source Control really make me think of DataObjects. It's interesting to see that their DG got rewritten : "However, you shouldn't expect 100 percent compatibility between DataGrid-based code and new GridView-based code." That means their implementation isn't that powerful ;) I found a bug in DG_R_DO : You use get_parent_class to check if the passed data is a dataobject. It failed with my dataobjects, because their not direct children of DB_DataObject, I use an intermediate class : it's pretty convenient and seems common, since the DO Generator provides options for it. Attached is a patch that : - corrects this DG_R_DO bug by using is_subclass_of instead of get_parent_class. - proposes a simple implementation for bind() to accept a dataobject, establishing a two-way interaction with it. It's pretty simple but it may help. Additionally : it works :) I've added a getSortField() function and some other thingies. Example usage : <html> <body> <?php error_reporting (E_ALL); require_once 'PEAR.php'; require_once 'DataObjects/Customers_companies.php'; require_once 'Structures/DataGrid.php'; $dataobject = new DataObj_Customers_companies(); // $dataobject->debugLevel(4); /* Be verbose */ $datagrid = new Structures_DataGrid(20); $datagrid->bind($dataobject); /* Just bind it (tm) */ echo $datagrid->render(); $r =& $datagrid->getRenderer(); $p = $r->getPaging(); echo "<br>$p"; ?> </body> </html> -- og

« previous php.pear.dev (#32594) next »