Page 1 of 1
"rows per page selection field" on browse forms for selection by the user
Posted: Fri Jan 21, 2022 11:33 am
by Andrea
Hi all,
is it possible to have a "rows per page selection field" on browse forms for selection by the user?
I tried but can't find the right place to start with code.
Many thanks in anticipation.
Andrea
Re: "rows per page selection field" on browse forms for selection by the user
Posted: Fri Jan 21, 2022 11:40 am
by kev1n
Hi Andrea,
Do you mean a filter where the user can set the number of rows per page?
Re: "rows per page selection field" on browse forms for selection by the user
Posted: Fri Jan 21, 2022 11:56 am
by Andrea
Hi kev1n,
yes, this would be great!
Best wishes
Andrea
Re: "rows per page selection field" on browse forms for selection by the user
Posted: Fri Jan 21, 2022 12:55 pm
by kev1n
In the form's Custom Code (Browse), add this JS to add a select element on top of a Browse Screen:
Code: Select all
function addRowsPerPageFilter(id) {
const data = [10, 20, 30, 50, 70, 100];
const hk = 'ROWS_PER_PAGE';
const style = 'margin-left: 20px; width: 120px; height: 22px; text-align: left';
var obj = $('<select style="' + style + '" id="' + id + '" />');
obj.append($('<option>', {
value: '',
text: nuTranslate('Number of Rows'),
disabled: true,
selected: true
}))
for (let val in data) {
$("<option />", {
value: data[val],
text: data[val]
}).appendTo(obj);
}
$('#nuActionHolder').append(obj);
obj.on("change", function() {
nuSetProperty(hk, this.value);
nuSetProperty('page_number', 0);
nuSetProperty(hk, this.value);
nuSearchAction();
});
$('#' + id).val(nuGetProperty(hk) === undefined ? '' : nuGetProperty('ROWS_PER_PAGE'));
}
addRowsPerPageFilter('rppselectId');
You will need to replace nuform.php in the /core directory.
nuform.zip
Re: "rows per page selection field" on browse forms for selection by the user
Posted: Fri Jan 21, 2022 2:40 pm
by kev1n
I just updated the js again.
Re: "rows per page selection field" on browse forms for selection by the user
Posted: Sat Jan 22, 2022 10:18 am
by Andrea
Hi Kev1n,
this is wonderful! Many thanks!!! This feature is very useful

I made some little changes in the js to prepend the select box and show the default number of rows, so I can reduce width of the select box:
Code: Select all
function addRowsPerPageFilter(id) {
const data = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
const hk = 'ROWS_PER_PAGE';
const style = 'margin-left: 20px; width: 50px; height: 22px; text-align: left';
var obj = $('<select style="' + style + '" id="' + id + '" />');
obj.append($('<option>', {
value: '',
// text: nuTranslate('Number of Rows'),
text: nuGetProperty('rows'),
disabled: true,
selected: true
}))
for (let val in data) {
$("<option />", {
value: data[val],
text: data[val]
}).appendTo(obj);
}
// $('#nuActionHolder').append(obj);
$('#nuActionHolder').prepend(obj);
obj.on("change", function() {
nuSetProperty(hk, this.value);
nuSetProperty('page_number', 0);
nuSetProperty(hk, this.value);
nuSearchAction();
});
$('#' + id).val(nuGetProperty(hk) === undefined ? '' : nuGetProperty('ROWS_PER_PAGE'));
}
I call it in "setup code" :
Code: Select all
function nuOnLoad() {
if (nuFormType() == 'edit') {
// Edit Form loaded
} else
if (nuFormType() == 'browse') {
// Browse Form loaded
addRowsPerPageFilter('rppselectId');
...
You had a lot of work in nuform.php! Will this nuform.php be part of future releases from now on?
Thanks a lot for this wonderful feature!
Have a nice weekend &
Best wishes
Andrea

Re: "rows per page selection field" on browse forms for selection by the user
Posted: Sat Jan 22, 2022 10:28 am
by kev1n
Yes, the nuform.php change is already on Github.
Re: "rows per page selection field" on browse forms for selection by the user
Posted: Tue Jan 25, 2022 5:23 pm
by Andrea
Thank you!!!
Best wishes
Andrea