Re: Structures_DataGrid_Renderer_Pager: showing the page that contains a given entry

From: Date: Wed, 10 Jan 2007 11:50:51 +0000
Subject: Re: Structures_DataGrid_Renderer_Pager: showing the page that contains a given entry
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26309@lists.php.net to get a copy of this message
Hi Sylvain, Sylvain Beucler wrote:
I'd like to do use Structures_DataGrid to show a list of data entries, with a Pager to show those entries split on several pages, and be able to select a page by saying "show me the page that contains data X".
Interesting point. One of the most useful example IMO is a select box as shown here: http://groups.google.com/groups/dir?hl=en&sel=33554433 (I talk about the "Usenet" dropdown: "1 ... ar", "arc ... bit", etc...)
Sample use cases: you show a list of users (thousands of users) using Structures_DataGrid, and with the Pager renderer, 20 users per page.
I assume you're just talking about user management as an example. But if that's really your purpose, I believe the best thing could be to make a new Structures_DataGrid_DataSource_LiveUser driver.
- when you click on a user, you go to the user's edition page, and there, the same Structures_DataGrid array shows the page that contains the user you're editing (instead of getting back to the first page).
This is easy to do.
- show entries "starting with" a given one. E.g.: there's a search box in the users list page where you can type a username's first letter in. If you type 'B', then you show the list of users starting with 'B', but then also the users starting with 'C' if there's still room for it, then 'D', etc. I mean: do not just restrict the data input to users starting with 'B' - if there's only 1 such users a one-liner array will look a bit weird. For SQL, I guess this would require a quick query to know the position of a given element according to the current sorting constraints (SELECT COUNT(*) FROM my_users_table WHERE login_name < 'B' ORDER BY login_name DESC...) and adapt the LIMIT accordingly.
For this simple alphabetic condition, I thing there's no need for an additionnal query. One query should be sufficient: SELECT * FROM my_users_table WHERE login_name >= 'b' ORDER BY login_name ASC; However, for the google example mentioned above, a scanning query is obviously needed.
Is there a way to do that with Structures_DataGrid? Otherwise, could this make a feature request, or is the package architecture just not meant for that?
Structures_DataGrid does not yet provide such a neat feature. But it's precisely its purpose to provide that kind of thing. The package architecture is meant for it, however it is a work in progress. Your idea would for example need something like the filter() method mentioned in TODO 19: http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/TODO?revision=1.21&view=markup Then you should write a new renderer driver which job is strictly to render such filtering forms. Feel free to help us on this issue, a feature request, especially if it contains a patch, would be greatly appreciated ;) Regards, -- Olivier

« previous php.pear.general (#26309) next »