Default Sort Order in Dadabik 4.3

Simun

New member
Merry Xmas and Happy New Year All,(tu);)

I feel like this might be a stupid question, but I have heard it said that the only stupid questions are the ones that are not asked.

So, is there a simple way of setting the default search order for a table to one specific or specific multiple columns?

Examples might be :-

1) Last name then First name.
or
2) County then City.

I know that the Dadabik administrator can cause initial display to be in a specific single order on one field by appending single field sort order parameters in the address bar.

so

../index.php?table_name=mytable&function=search&records_per_page=500

would become

../index.php/?table_name=mytable&function=search&records_per_page=500 &where_clause=&page=0&order=city&order_type=ASC

to order them by a City field in ascending order.

However, this is not easily accessible as a method for me because I have the login process to go through first and the initial results for my single table are displayed automatically after that.

I also know that the person viewing can click a specific field title once or twice to sort the results by that field in Ascending and Descending orders respectively.

But either way described only works for a single field.

So there are two questions really.

  1. How to set a default search order to a single specific field?
  2. How to set a sort order based upon two fields if indeed this is possible?

Both cases involving a user login first of all.

Any help greatly appreciated.

Kind Regards,

Simon
 

eugenio

Administrator
Staff member
Simun Wrote:
-------------------------------------------------------
> Merry Xmas and Happy New Year All,(tu);)

Happy New Year to you too :)

> I feel like this might be a stupid question, but I
> have heard it said that the only stupid questions
> are the ones that are not asked.

Nice tip ;)

> So, is there a simple way of setting the default
> search order for a table to one specific or
> specific multiple columns?

A quick hack: in index.php you can see two times (one for "normal" tabes the other for "linked" table) this piece of code
if (!isset($order)){
I guess (no tested) that if you put there something like
if ($table_name === 'mytable') $order = 'myfield';
you can set a default order field. Just one, two fields required more code changes.
 

Simun

New member
I found 'quick and dirty' way utilising the information that you provided.

This implementation concerns a single table. So I was able to set the default search order to column 9 in both places.

[pre]
if (!isset($order)){
// get the first field present in the results form as order - simon changed this to the city column
$count_temp = 8;
[/pre]

Many Thanks.
 
Top