Page 1 of 1

Pager and PageSizeSelector are not shown

Posted: Thu Sep 05, 2024 3:51 am
by sangnandar

Table:
demo/employeeslist (less than 10 records)

Advanced Settings:

  • Auto hide paging section if single page -> ON
  • Allow no paging section -> OFF
  • Auto hide page size selector if single page -> OFF

Behavior on demo/employeeslist (not expected):
Pager -> OFF
PageSizeSelector -> OFF

Expected behavior:
Pager -> OFF
PageSizeSelector -> ON

Thank you.


Re: Pager and PageSizeSelector are not shown

Posted: Thu Sep 05, 2024 9:16 am
by arbei

If the page size (e.g. 10) is larger than actual records (<10), there is only one page and therefore page size selector is not shown.


Re: Pager and PageSizeSelector are not shown

Posted: Thu Sep 05, 2024 9:33 am
by mobhar

If you want to display back the PageSizeSelector, then you may simply append this string in current URL, for example: ?recperpage=5


Re: Pager and PageSizeSelector are not shown

Posted: Thu Sep 05, 2024 10:28 am
by sangnandar

arbei wrote:

If the page size (e.g. 10) is larger than actual records (<10), there is only one page and therefore page size selector is not shown.

Wouldn't that be contrary to the rule of Advanced Settings -> Auto hide page size selector if single page -> OFF ? Meaning, if it's single page then PageSizeSelector is NOT auto-hide.
Moreover, with this behavior, "Auto hide paging section if single page" and "Auto hide page size selector if single page" will be redundant. "Auto hide paging section if single page" controls both Pager and PageSizeSelector while "Auto hide page size selector if single page" is completely irrelevant.

It will also be problematic for user. Consider below scenario:

  • RecordCount = 89
  • Default page size = 10 records/page, with selector 10, 50, 100, ALL
  • when user open the page for the first time, it will be 10 records/page
  • user changes page size to 100
  • page size selector is now gone
  • user can't go back to 10 records/page
  • append ?recperpage into the url is not possible because user is ... well... user

Re: Pager and PageSizeSelector are not shown

Posted: Thu Sep 05, 2024 12:28 pm
by arbei

From the source code:

// Page size selector
if ($this->UsePageSizeSelector && !empty($this->PageSizes) && !($this->AutoHidePageSizeSelector && $this->RecordCount <= $this->PageSize)) {
  1. If "Auto hide page size selector if single page" is on, but the page size (e.g. 10) is larger than actual records (<10), there is only one page and therefore page size selector is not shown.
  2. If "Auto hide page size selector if single page" is off, the page size selector will show.
  3. The UsePageSizeSelector property is true in List page by default, make sure you did not set it as false, or it will never show.
  4. After changing the advanced settings, make sure you generate the config.php again, not just pages for the table.
  5. In case the true/false settings are incorrectly saved, enable and disable again (or vice versa), save the project and generate the config.php again, open it and check the settings are as you set, look for:
        // Auto hide pager
        "AUTO_HIDE_PAGER" => true,
        "AUTO_HIDE_PAGE_SIZE_SELECTOR" => false,

Re: Pager and PageSizeSelector are not shown

Posted: Thu Sep 05, 2024 7:37 pm
by sangnandar

I've played with Pager.php and PrevNextPager.php before. I think the problem isn't in that line but in $this->isVisible()

    // Pager.php

    // Is visible
    public function isVisible()
    {
        // return $this->RecordCount > 0 && $this->Visible; // somehow this line return false
        return true;
    }

    // Render
    public function render()
    {
        global $Language;
        $html = "";
        $formatInteger = self::$FormatIntegerFunc;
        if ($this->isVisible()) {
            // Do not show record numbers for View/Edit page
            if ($this->PagePhraseId !== "Record") {

Forcing $this->isVisible() to true solve the problem for PageSizeSelector. It's shown for single page.
BUT, since this function is also called by PrevNextPager.php this will also set Pager to be shown for single page.

    // PrevNextPager.php 

    // Render
    public function render()
    {
        global $Language;
        $html = "";
        if ($this->isVisible()) {
            $url = $this->Url ?? CurrentDashboardPageUrl();
            $useAjax = $this->Table->UseAjaxActions;

Hence my conclusion that function isVisible() controls both Pager and PageSizeSelector.