Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.3

Bug #4375 Can't change colum links
Submitted: 2005-05-18 07:47 UTC
From: keith at setuplinux dot com Assigned: olivierg
Status: Closed Package: Structures_DataGrid
PHP Version: 5.0.3 OS: Gentoo
Roadmaps: (Not assigned)    
Subscription  


 [2005-05-18 07:47 UTC] keith at setuplinux dot com
Description: ------------ Have a query with a where clause that's submited from the previous page. When I click on the sort links that are the column headers it re-loads the page and the submited values from the previous page are gone and there is no way for me to put them in the column headers links. Reproduce code: --------------- $search = $_POST['search']; $sql = " select id, name_last, name_first, uid from contacts where name_first ilike '%$search%' OR name_last ilike '%$search%' OR uid ilike '%$search%'"; require_once('Structures/DataGrid.php'); $column = new Structures_DataGrid_Column('User ID', 'id', 'id', null, '--'); $dg->addColumn($column); $column = new Structures_DataGrid_Column('Last Name', 'name_last', 'name_last', null, '--'); $dg->addColumn($column); $column = new Structures_DataGrid_Column('First Name', 'name_first', 'name_first', null, '--'); $dg->addColumn($column); $dg->bind($db->getAll($sql, DB_FETCHMODE_ASSOC)); $dg->render(); echo $dg->renderer->getPaging(); Expected result: ---------------- I expect to get my results (which happens) and I expect when I click on the sort links column headers that it will not re-query with missing data, or that there will be away I can add the query variables needed to the links in the column headers. Actual result: -------------- I get the initial expected results, but when I click on any of the column header links it's reloads the page with none of the values set from the previous page which basically returns all possible results. Basically there needs to be a way to pass variables in the column header links, or pass the previous resluts to the new page so it no additional queries are needed

Comments

 [2005-05-24 12:52 UTC] post at mark-wiesemann dot de
I second this request. Maybe some piece of code from Pager package can be used here, the code for generating the links was improved in the last release. Important are the Pager options "importQuery" (true/false, import variables from query string), "extraVars" (optional, array with more variables for the new query string), "excludeVars" (optional, array with variables that may not go into the query string). I'd like to help with this but don't have the time for it in the next two weeks.
 [2005-05-27 14:12 UTC] asnagy
Could you possibly include a URL so I can see it? I am doing this currently in a live project and it works fine for me. I have a list of items and a way to filter the list down. When i click on the sort links, the filter stays in the querystring. I would like to see you implementation so I can debug it
 [2005-05-27 15:21 UTC] post at mark-wiesemann dot de
Hmm, has this changed recently? Last time I tried it (sometime in last year), additional (filter) variables got lost. With current CVS code it now works as expected in my scripts. But maybe the "extraVars" and "excludeVars" options from Pager package would be a nice addition to SDG.
 [2005-07-13 16:44 UTC] asnagy
The 'extraVars' and 'excludeVars' can be used by specifying them in the getPaging method. It seems that everything that is being asked for can be done already. Let me know if you are still unable to accomplish what you are trying to do.
 [2005-10-07 00:15 UTC] olivierg at php dot net
This bug has been fixed in CVS. Read on for more informations. There indeed was no way to add an extra GET argument to the query string used by the sort links (table headers). Additionally, to add a such extra GET argument to the paging links, one needed a very ugly statement, as : $pagerOptions = array ('extraVars' => array ('search' => $search)); $dg->renderer->getPaging( $mode = 'Sliding', $separator = '|', $prev = '<<', $next = '>>', $delta = 5, $attrs = $pagerOptions); I have implemented a new method which allow to add extra GET variables to both paging and sorting links in one call : setExtraVars(). For consistency across packages, it has a similar name to Pager's 'extraVars' option. In your case, Keith, simply call : $dg->renderer->setExtraVars (array ('search' => $search)); But, when integrated to the paging and sorting links, the 'search' variable will come through GET, not POST. So, at the top of your script, instead of : $search = $_POST['search']; you should write : $search = $_REQUEST['search'];