Re: Structures/Datagrid - sorting on field prior to display with csv data source?
| From: | Mark Wiesemann | Date: | Mon, 01 Jan 2007 19:57:42 +0000 |
| Subject: | Re: Structures/Datagrid - sorting on field prior to display with csv data source? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26238@lists.php.net to get a copy of this message | ||
Hi Scott,
ScottZ wrote:
> Not sure what is wrong then.
> I tried it with php 5.2.0 on my local windows box and on a remote unix
> box. [...]
> Here's the CSV (now called names.csv)
>
> ln,fn,mi,num
> Jones,John,T,9034
> Allen,Mary,S,3045
> Smith,Anna,J,5074
> Castel,Ed,A,7043
>
> Here's the code:
[...]
> $dgOptions["labels"] = array (
> "ln" => "Last",
> "fn" => "First"
> );
>
> $preSort["Last"] = "ASC";
[...]
I have looked at the described issue. It is not a bug in
Structures_DataGrid, it is a small problem in your code.
Just change
$preSort["Last"] = "ASC";
into
$preSort["ln"] = "ASC";
and your the sort link in the table header will work as expected.
You have to use the "field name" (i.e. the name that is used in the
first row of the CSV file in your case) and not the label as the array
key for the setDefaultSort() call.
Regards,
Mark