Options List sort order

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Options List sort order

Post by pfrumkin » 2020-07-08 21:56

Hi,

It seems that the Options List is always sorted alphabetically. Anyone know if there is a way to get the Options List to display in the order I provide (and not sort it alphabetically for me)? I found viewtopic.php?t=1586 was going along this line but there was not enough information there, and maybe not the same use case so I created separate post.

I exactly have the Payment Type Options List Cash;;Credit Card;;Check;;Other
but it displays
  • Cash
  • Check
  • Credit Card
  • Other
not what I want.

Thanks.

~Paul

AppGini 5.82

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 278
Joined: 2018-03-04 09:30
Location: Orlando, FL

Re: Options List sort order

Post by D Oliveira » 2020-07-10 02:11

on mobile devices you're hopeless, seems to be default and fixed, in tableview if thats what you're looking for (desktop only) go to your tablename_view.php file and find:

Code: Select all

	$x->ColCaption = array( "colname1", "colname2", "colname3");
	$x->ColFieldName = array('kcal', 'fat', 'carbs');
	$x->ColNumber  = array(12, 14, 16);


pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1321
Joined: 2018-04-01 10:12

Re: Options List sort order

Post by pböttcher » 2020-07-10 06:14

Hi,

can you please post a screenshot. I was not able to reproduce your case. On my system it shows the option list in the order I provide in the option list defintion.
option_list.png
option_list.png (5.86 KiB) Viewed 3681 times

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-10 15:52

:cry:
OptionsList.png
OptionsList.png (15.52 KiB) Viewed 3658 times

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 278
Joined: 2018-03-04 09:30
Location: Orlando, FL

Re: Options List sort order

Post by D Oliveira » 2020-07-10 17:59

oh in that case you might wanna check tablename_dml.php

Code: Select all

$combo_statusp->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("option1;;option2;;option3")));
or list it like that:

Code: Select all

1- Cash
2- Credit Card
3- ..

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1321
Joined: 2018-04-01 10:12

Re: Options List sort order

Post by pböttcher » 2020-07-10 18:25

What version of AppGini are you using?

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-10 22:56

@D Oliveira
$combo_Payment_Type->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("Cash;;Credit Card;;Check;;Other")));

@pböttcher
AppGini 5.82 Revision 1101

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1321
Joined: 2018-04-01 10:12

Re: Options List sort order

Post by pböttcher » 2020-07-11 11:12

Are you using any other script or is that native?
Can you create a small nativ test app and see if it has the same issue?

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-12 17:05

Sorry I don't understand. There is a dv.js file. Otherwise this is out of the box AppGini. I also did this with a .csv file, same result. It seems that it is alphabetizing the result.

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1321
Joined: 2018-04-01 10:12

Re: Options List sort order

Post by pböttcher » 2020-07-12 17:19

Can you post your dv.js file (or rename it and see if it still happens)

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-13 14:54

I was wrong, there is no JS files. There is a one line format statement (added recently, after we'd seen this sorting) in the _dv hook, otherwise nothing in the hooks file either.

We had prefixed the options with spaces to "encourage" the sorting I wanted, but we found it wasn't saving the data that way so we had to remove the spaces.

User avatar
zibrahim
Veteran Member
Posts: 85
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Options List sort order

Post by zibrahim » 2020-07-14 00:10

Hi Guys,
I am having similar issue as well.
Screen Shot 2020-07-14 at 8.06.30 AM.png
Screen Shot 2020-07-14 at 8.06.30 AM.png (143.91 KiB) Viewed 3516 times
Screen Shot 2020-07-14 at 8.07.24 AM.png
Screen Shot 2020-07-14 at 8.07.24 AM.png (43.96 KiB) Viewed 3516 times
Any help is appreciated.
Thanks.

Zala.
Zala.
Appgini 5.97, MacOS 11.4 Windows 10 on Parallels.

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-17 16:33

Well, I did a total hack :twisted: . When I did View Source I found

Code: Select all

<script>jQuery(function(){ 
jQuery("#Payment_Type")
	.addClass('option_list')
	.select2({ 
		minimumResultsForSearch: 5,
		sortResults: AppGini.sortSelect2ByRelevence
	}); 
})</script>
In my tablename_dv hook, I added

Code: Select all

	$html = str_replace('AppGini.sortSelect2ByRelevence', ';', $html);
This effectively makes this sort a no-op. So as written, this has the unintended side effect of removing all such sorting on the form so handle with care. I had one other field on the form that has this and not sorting is ok.

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-27 17:14

Perhaps predictably (sigh) my hack didn't work. I am now experimenting with an expansion

Code: Select all

		$html = str_replace('AppGini.sortSelect2ByRelevence', 'function(res, cont, qry) {
			return res.sort(function(a, b) { return false; });  }', $html);
I dug into the definition of AppGini.sortSelect2ByRelevence and tweaked it to get the result I wanted. There is too much about this that I don't understand (not knowing JS very well) but I don't have time to dig further :cry: .

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1321
Joined: 2018-04-01 10:12

Re: Options List sort order

Post by pböttcher » 2020-07-27 17:46

Hi,

can you create an app like this and tell if the sorting still happens.
sort.png
sort.png (123.11 KiB) Viewed 3368 times

User avatar
zibrahim
Veteran Member
Posts: 85
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Options List sort order

Post by zibrahim » 2020-07-28 07:56

Hi pböttcher,
I have tried as requested and sorting is not as expected.
Please refer below images.

Thanks.
Screen Shot 2020-07-28 at 3.54.33 PM.png
Screen Shot 2020-07-28 at 3.54.33 PM.png (75.25 KiB) Viewed 3345 times
Screen Shot 2020-07-28 at 3.54.12 PM.png
Screen Shot 2020-07-28 at 3.54.12 PM.png (51.93 KiB) Viewed 3345 times
Zala.
Appgini 5.97, MacOS 11.4 Windows 10 on Parallels.

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-07-28 19:33

Thanks for that follow up Zala! It was going to take me another day to get there.

User avatar
zibrahim
Veteran Member
Posts: 85
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Options List sort order

Post by zibrahim » 2020-07-30 08:41

A quick update on this issue.
I found that this sorting issue happen when I run it in my XAMPP (ver 7.4.1).
It is working properly on the actual server and this is NOT Appgini problem.
I will try on other version of XAMPP later and update the outcome.
Thanks Pascal for helping.

Zala.
Zala.
Appgini 5.97, MacOS 11.4 Windows 10 on Parallels.

User avatar
zibrahim
Veteran Member
Posts: 85
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Options List sort order

Post by zibrahim » 2020-07-30 13:19

I have installed the latest XAMPP 7.4.8 and after testing, it didn’t do the sorting as expected.
I am not sure what is wrong with XAMPP but since it is not a big issue, I will leave it as it is.
As long it is working properly in the actual server, it is good for me.
Hope this clear the issue that it is not Appgini problem.
Thank you and have a nice day.

Zala.
Zala.
Appgini 5.97, MacOS 11.4 Windows 10 on Parallels.

pfrumkin
Veteran Member
Posts: 147
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Options List sort order

Post by pfrumkin » 2020-08-02 17:48

Thanks for that additional follow up Zala, and Pascal.

Post Reply