Tried that. The Fruits table displays correctly, by name order.
But Fruit names in the quantity table are still ordered by id.
Kim
Ian VanDerPoel wrote:
>Kim,
>
>Sorry Kim, I have specified this incorrectly. I was not thinking straight. The
>has_many has the order_by clause. The original fix that I posted should work.
>You just need to modify it to suit your code.
>
>You need to overide the "order" method in table Fruits with
>
>sub order { return ( 'name' ); } # as in name = the column name in Fruits
>
>I hope this works.
>
>
>
>>>>Kim Ryan <[EMAIL PROTECTED]> 14/07/06 8:51 AM >>>
>>>>
>>>>
>Tried that but the sort order is still not what I want. This applies
>both to a select list, and listing a table with a has_a join. Results
>still sorted by the id of the join and not the name.
>
>Thanks,
>
>Kim
>
>Ian VanDerPoel wrote:
>
>
>
>>Kim,
>>
>>I am not sure how you populate the list but if you modify your has_a
>>declaration to
>>
>>MyApp::Orders->has_a(fruit_id => "MyApp::Fruits",{order_by=>'fruit_name'});
>>
>>it should do the trick.
>>
>>Regards
>>
>>Ian
>>
>>
>>
>>
>>
>>>>>Kim Ryan <[EMAIL PROTECTED]> 13/07/06 4:11 PM >>>
>>>>>
>>>>>
>>>>>
>>>>>
>>Hi Ian,
>>
>>I added in the order sub. If I simply list my fruit table,
>>it is sorted alphabetically by fruit name which is good.
>>
>>The problem occurs when another table just stores the fruit id,
>>and I join across to the fruit table to replace the id with
>>the full name.
>>
>>For example in table orders
>>
>>quantity fruit_id
>>
>>10 2
>>5 1
>>4 3
>>
>>
>>MyApp::Orders->has_a(fruit_id => "MyApp::Fruits");
>>
>>A select list built from fruit_id will still display
>>
>>Apple
>>Banana
>>Pear
>>Orange
>>
>>even with an order sub in place for fruits
>>
>>Regards,
>>
>>Kim
>>
>>
>>
>>
>>
>>Ian VanDerPoel wrote:
>>
>>
>>
>>
>>
>>>Kim,
>>>
>>>You need to overide the ORDER method for that table. Something like:
>>>
>>>sub order {
>>> my ($self, $r) = @_;
>>> return ($self->SUPER::order($r) || 'fruit' );
>>>}
>>>
>>>I hope this makes sense.
>>>
>>>Regards
>>>
>>>Ian
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>>Kim Ryan <[EMAIL PROTECTED]> 13/07/06 3:37 PM >>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>HI all,
>>>
>>>I have some fairly long select lists to display. I use the has_a
>>>method so the contents of the select list are drawn from a database table.
>>>When I initially create the table I can control the sort sequence, such as
>>>
>>>Apple, value = 1
>>>Banana, value = 2
>>>Pear, value = 3
>>>.....
>>>
>>>and they will appear in that order. A problem occurs when I
>>>want to add "Orange, value =4", it will be at the end of the list.
>>>
>>>Is there a way to have select lists sorted alphabetically?
>>>
>>>Thanks,
>>>
>>>Kim
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>-------------------------------------------------------------------------
>>Using Tomcat but need to do more? Need to support web services, security?
>>Get stuff done quickly with pre-integrated technology to make your job easier
>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>_______________________________________________
>>Maypole-users mailing list
>>[email protected]
>>https://lists.sourceforge.net/lists/listinfo/maypole-users
>>
>>
>>
>>_____________________________________________________________________
>>This message (including any attachments) is intended solely for the addressee
>>named and may contain confidential and or privileged information. If you are
>>not the intended recipient, please delete it and notify the sender. Views
>>expressed in this message are those of the individual sender, and are not
>>necessarily the views of the Ministry of Transport (MoT) or The Independent
>>Transport Safety Reliability Regulator (ITSRR) or The Office of Transport
>>Safety Investigation (OTSI). Whole or parts of this e-mail may be subject to
>>copyright of the Ministry or third parties. You should only re-transmit,
>>distribute or use the material for commercial purposes if you are authorised
>>to do so.
>>
>>-------------------------------------------------------------------------
>>Using Tomcat but need to do more? Need to support web services, security?
>>Get stuff done quickly with pre-integrated technology to make your job easier
>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>_______________________________________________
>>Maypole-users mailing list
>>[email protected]
>>https://lists.sourceforge.net/lists/listinfo/maypole-users
>>
>>
>>
>>
>>
>>
>
>
>
>_____________________________________________________________________
>This message (including any attachments) is intended solely for the addressee
>named and may contain confidential and or privileged information. If you are
>not the intended recipient, please delete it and notify the sender. Views
>expressed in this message are those of the individual sender, and are not
>necessarily the views of the Ministry of Transport (MoT) or The Independent
>Transport Safety Reliability Regulator (ITSRR) or The Office of Transport
>Safety Investigation (OTSI). Whole or parts of this e-mail may be subject to
>copyright of the Ministry or third parties. You should only re-transmit,
>distribute or use the material for commercial purposes if you are authorised
>to do so.
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>Maypole-users mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/maypole-users
>
>
>
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users