PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Sorting with Array as DataSource

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures
View previous topic :: View next topic  
Author Message
FlipFlop



Joined: 06 Aug 2007
Posts: 7

PostPosted: Wed Aug 29, 2007 7:51 pm    Post subject: Sorting with Array as DataSource Reply with quote

Hi again,

I have troubles with sorting (clicking on the column header) on a SDG generated table. I have the following code:
Code:

$dg =& new Structures_DataGrid(20);
$dg->addColumn(new Structures_DataGrid_Column('Signed'          , 'signed'        , 'signed'        , null, null, 'HasSigned()'));
$dg->addColumn(new Structures_DataGrid_Column('Forename'        , 'forename'      , 'forename'      , null, null, ''));
$dg->addColumn(new Structures_DataGrid_Column('Surname'         , 'surname'       , 'surname'       , null, null, ''));
...
...
// Bind datasource
$res = $dg->bind($Members);

$Members is an normal array that looks like:
Code:

[UID]['signed'][TRUE]
     ['forename']['whatever']
     ['lastname']['same']
     ...
     ...

SDG does display the table correctly but if I try to sort any column, the order will change but not right at all. In the GET vars I can see that SDG want do it right because of this: orderBy=forename&direction=ASC&page=1

Does someone have an idea why sorting wont work as expected?

greats mike
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Wed Aug 29, 2007 8:27 pm    Post subject: Reply with quote

Your $Members example looks a little bit weird. Can you please show the output of var_dump($Members); (from the start until the end of the first row)?
Back to top
View user's profile Send private message
FlipFlop



Joined: 06 Aug 2007
Posts: 7

PostPosted: Thu Aug 30, 2007 10:02 am    Post subject: Reply with quote

Sure, here it is:
Code:
array(43) { [1]=> array(27) { ["forename"]=> string(7) "Herbert" ["surname"]=> string(8) "Mattulik" ["street"]=> string(12) "Hauptstrasse" ["postcode"]=> NULL ["city"]=> NULL ["to_country"]=> string(7) "Austria" ["dateofbirth"]=> string(19) "1960-01-01 00:00:01" ["email"]=> NULL ["url"]=> NULL ["phone"]=> NULL ["to_status"]=> string(8) "Mitglied" ["active"]=> int(1) ["signed"]=> int(0) ["joiningdate"]=> string(19) "2007-07-25 00:00:01" ["contribution"]=> NULL ["to_contrstatus"]=> string(10) "1. Mahnung" ["comment"]=> NULL ["createdon"]=> string(19) "2007-07-25 18:03:25" ["createdby"]=> string(5) "Berni" ["newsletter"]=> int(0) ["Id"]=> int(1) ["BMX"]=> int(0) ["Inline"]=> int(2) ["Skateboard"]=> int(0) ["Streetboard"]=> int(0) ["Freestyle MTB"]=> int(0) ["Other"]=> int(99) }
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Thu Aug 30, 2007 3:03 pm    Post subject: Reply with quote

Okay, the array structure looks right.

Which PHP version do you use? Do you have the latest versions of SDG and the array DataSoure driver installed?

And how is the sorting "not right at all"? (If you want, send me a screenshot of the wrong sorting to wiesemann(at)php.net.)
Back to top
View user's profile Send private message
FlipFlop



Joined: 06 Aug 2007
Posts: 7

PostPosted: Thu Aug 30, 2007 3:58 pm    Post subject: Reply with quote

I'm using PHP Version 5.2.0.
SDG:
Structures_DataGrid has version 0.8.3 beta and
Structures_DataGrid_DataSource_Array has version 0.1.2 beta

After binding I use the Smarty Renderer for output but that shouldn't make any difference, or?

A screenshot is on the way...

Thanks
Mike
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software