Page 1 of 1

How to Sort Two Fields?

Posted: 2023-05-24 11:30
by mohamed
Hello,

in AppGini I am allowed/able to Sort a Single Field per table using the "Default Sort By" option.

Is there a way to Sort on two (2) Fields/Columns ?


THANK YOU

Re: How to Sort Two Fields?

Posted: 2023-05-24 13:21
by jsetzer
Check out DefaultSortField property of $options in TABLENAME_init hook

Docs:
https://bigprof.com/appgini/help/advanc ... ist-object

Re: How to Sort Two Fields?

Posted: 2023-05-24 19:28
by mohamed
Thanks JAN,

I am able now to do the sorting (following two links in the Forum - forgot the links :(

that I have to do the following two steps:

1. Set Default Sort by to None in the Table using AppGini app

2. edit the TableName.PHP file and Configure the function TableName_init

Code: Select all

	function  TableName_init(&$options, $memberInfo, &$args) {

		$options->DefaultSortField = '4 asc, 5 asc';
		$options->DefaultSortDirection = '';

		return TRUE;
	}

Is there documentation of $Options ?


Thanks again..

Re: How to Sort Two Fields?

Posted: 2023-05-24 19:53
by jsetzer
Is there documentation of $Options ?
Yes, see the link I've given above.

Re: How to Sort Two Fields?

Posted: 2023-05-24 19:56
by jsetzer
$options->DefaultSortField = '4 asc, 5 asc';
I think you can also use fully qualified column names like this:

Code: Select all

$options->DefaultSortField = 'tablename.column_x DESC, tablename.column_y';
May be easier to read and easier to maintain when changing order of fields.

Re: How to Sort Two Fields?

Posted: 2023-05-25 17:35
by mohamed
Hi Jan,

Cool .. THANK YOU big time ..

Regards..