#1
If I create a module using Trongate DA and access pagination options a 404 will appear if there are not enough records.

eg if you change the "records per page" 10 to 20.

How do we code around that please? Been stuck on that for a while.

Thank you

Darron
#2
Hey Darron,
Need more information.
What is the url you are trying to access when you get the error?

Dan
#3
Hi Dan

I have created a simple test module with fields lastname, firstname, company name

I have added three records. On the manage page there is pagination and you can choose to view 10, 20, 50, 100 records.

If I click any of those 404 will appear.

http://localhost:8080/page_test/page_tests/manage

Thanks

D
#4
Darron,
Did you copy all the functions ?
$pagination_data['limit'] = $this->_get_limit();

$data['rows'] = $this->_reduce_rows($all_rows);
$data['selected_per_page'] = $this->_get_selected_per_page();
$data['per_page_options'] = $this->per_page_options;
// This is set at the top of the controller file:
private $per_page_options = array(10, 20, 50, 100);
Need to add these function to the Controller file
function _get_limit() {
if (isset($_SESSION['selected_per_page'])) {
$limit = $this->per_page_options[$_SESSION['selected_per_page']];
} else {
$limit = $this->default_limit;
}
return $limit;
}

function _get_selected_per_page() {
if (!isset($_SESSION['selected_per_page'])) {
$selected_per_page = $this->per_page_options[1];
} else {
$selected_per_page = $_SESSION['selected_per_page'];
}

return $selected_per_page;
}

function _reduce_rows($all_rows) {
$rows = [];
$start_index = $this->_get_offset();
$limit = $this->_get_limit();
$end_index = $start_index + $limit;
$count = -1;
foreach ($all_rows as $row) {
$count++;
if (($count>=$start_index) && ($count
#5
Hi Dan

Everything is present here in the code. This is all generated by the Desktop App.

I checked everything from your reply in the controller file., the functions are here and the calls to them are in the manage function.

Thanks

D

[code]
#6
It seems like the OnClick is where the error occurs, in the view file.
What I would try is to rename the module.
Then use the desktop app to add a new module to your app.
Add some records and then try the pagination.
See what happens.

The only other thing I can think of is to change the License version and update your app

Dan
#7
Hi Darron,

I think Dan is correct in suggesting to rename your old module and create a new one, making sure you are on the current version, but it's not the Onclick you need to look at, it's the onchange

which calls setPerPage() function in admin.js


I just created a a module called page_tests with the same 3 input fields, added 3 records and pagination is working fine on all 10, 20, 50 & 100 settings.

Here is the manage.php view file:


And here is the Page_test.php controller that was generated with the Desktop app: