|
|
|
|
|
|
Login
|
erp5.org has permanently moved to wiki.erp5.org ! Current status of ERP5 community websites:
Note: if you created content in this ancient portal, please migrate it to the wiki. The old website will stay online as long as all contents are not mograted to the wiki.
Sorted Listboxes
This document will show you how to set your listboxes in order to be able to see them in a orderable way. It's very easy to set up some order, and, badly, often this feature is not used so much. So, thanks to this document, everyone will know that this is very easy and will use it a lot !
ListBox sort parameters:Sortable Columns: There is two fields in the listbox related to the sort. The first one is
title | Title
description | Description
The only important information is the left part. The right part is not used
at all. The left part must be exactly the same as the left part of the field
This field is not required, most of the time you can forget it. Indeed, if nothing is defined here, then it will takes values of "Searchable Columns", and if nothing is defined in "Searchable Columns", then the lisbox will look at mysql tables if he can find one table with the right column. Sortable Columns and MySQL:With MySQL, the only important thing to setup is to enter correctly the field "Columns". When you use MySQL queries, through portal_catalog or searchFolder for example, you MUST set the left part of columns with the value of the column id. This is a bad way of doing for the field "Columns" :
getTitle | Title
getDescription | Description
getWhateverIsNotInTables | Something
In the table catalog, we have a column called This is the right way of doing :
title | Title
description | Description
getWhateverIsNotInTables | Something
In the table catalog, we have a column called Default Sort:The second field related to sort is called "Default Sort". It defines the default sort used, for example you may want to sort by portal type and for all objets with the same portal type, you may want to sort by title. You can define this field like this:
portal_type | ascending
title | descending
Again, the left part is exactly like the left part of the field "Columns". The right part
defines if you want to order in ascending or descending way. If you put something else than
Don't forget that the default sort is stored in your selection. So if you change a listbox that you already used, then the new default sort will not be used. You have to reset your selection if you want to see the default sort, the one associated with the selection name of the listbox. Once you defined the default sort, then the list method of the listbox will be called with
a parameter
(('portal_type','ascending'),('title','descending'))
The sort_on parameter is a list of couples. The support if the sort_on parameter already exists in the catalog. It can handle the sort on several columns ordered in a different way. If you don't use the catalog, let's say that you use a script, then you need to modify your script so that it will be able to use the sort_on parameter. Conclusion : It is very simple to set sort parameters on listboxes. First, most of the time you don't need
to define the field Relation field and search:By the way, it's also possible to define the sort used to display a list of choice with a relation field, when you are redirected to the listbox of "Base_viewRelatedObjectList". Indeed, on all relation fields, there is a field "Default Sort" that will be used by the listbox of Base_viewRelatedObjectList. You can notice that you can also define the columns and some parameters. |
|
|