Page 1 of 1
Options List sort order
Posted: 2020-07-08 21:56
by pfrumkin
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
Re: Options List sort order
Posted: 2020-07-10 02:11
by D Oliveira
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);
Re: Options List sort order
Posted: 2020-07-10 06:14
by pbottcher
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 (5.86 KiB) Viewed 7052 times
Re: Options List sort order
Posted: 2020-07-10 15:52
by pfrumkin
- OptionsList.png (15.52 KiB) Viewed 7029 times
Re: Options List sort order
Posted: 2020-07-10 17:59
by D Oliveira
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:
Re: Options List sort order
Posted: 2020-07-10 18:25
by pbottcher
What version of AppGini are you using?
Re: Options List sort order
Posted: 2020-07-10 22:56
by pfrumkin
@D Oliveira
$combo_Payment_Type->ListItem = explode('||', entitiesToUTF8(convertLegacyOptions("Cash;;Credit Card;;Check;;Other")));
@pböttcher
AppGini 5.82 Revision 1101
Re: Options List sort order
Posted: 2020-07-11 11:12
by pbottcher
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?
Re: Options List sort order
Posted: 2020-07-12 17:05
by pfrumkin
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.
Re: Options List sort order
Posted: 2020-07-12 17:19
by pbottcher
Can you post your dv.js file (or rename it and see if it still happens)
Re: Options List sort order
Posted: 2020-07-13 14:54
by pfrumkin
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.
Re: Options List sort order
Posted: 2020-07-14 00:10
by zibrahim
Hi Guys,
I am having similar issue as well.
- Screen Shot 2020-07-14 at 8.06.30 AM.png (143.91 KiB) Viewed 6887 times
- Screen Shot 2020-07-14 at 8.07.24 AM.png (43.96 KiB) Viewed 6887 times
Any help is appreciated.
Thanks.
Zala.
Re: Options List sort order
Posted: 2020-07-17 16:33
by pfrumkin
Well, I did a total hack
. 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.
Re: Options List sort order
Posted: 2020-07-27 17:14
by pfrumkin
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
.
Re: Options List sort order
Posted: 2020-07-27 17:46
by pbottcher
Hi,
can you create an app like this and tell if the sorting still happens.
- sort.png (123.11 KiB) Viewed 6739 times
Re: Options List sort order
Posted: 2020-07-28 07:56
by zibrahim
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 (75.25 KiB) Viewed 6716 times
- Screen Shot 2020-07-28 at 3.54.12 PM.png (51.93 KiB) Viewed 6716 times
Re: Options List sort order
Posted: 2020-07-28 19:33
by pfrumkin
Thanks for that follow up Zala! It was going to take me another day to get there.
Re: Options List sort order
Posted: 2020-07-30 08:41
by zibrahim
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.
Re: Options List sort order
Posted: 2020-07-30 13:19
by zibrahim
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.
Re: Options List sort order
Posted: 2020-08-02 17:48
by pfrumkin
Thanks for that additional follow up Zala, and Pascal.