Jump to content


\IPS\Helpers\Table\Custom pagination issue

newbie LAC

Go to solution Solved by bfarber,

Recommended Posts


		$data = array();
		foreach (range(1,100) as $r)
			$data[] = array(
				'field1' => 'value' . $r

		$table = new \IPS\Helpers\Table\Custom(
		$table->quickSearch = 'field1';

		\IPS\Output::i()->output = (string) $table;


Search by value11



This is also affect on built in functions

E.g. SQL toolbox



Link to comment
Share on other sites

  • 2 months later...


On 7/29/2019 at 10:18 PM, bfarber said:

Thanks, I've added an internal bug report to get this checked into.

Your fix broke some my custom tables. I don't use quick search and pass to $dataSource X items returned for current page

Could you change this?

For example move

        $this->count = \count( $rows );
        $this->pages = ceil( $this->count / $this->limit );


        if ( $this->quickSearch !== NULL and \IPS\Request::i()->quicksearch )
            $quickSearchColumn = $this->quickSearch;
            $rows = array_filter( $rows, \is_callable( $this->quickSearch ) ? $this->quickSearch : function( $row ) use ( $quickSearchColumn )
                return mb_strpos( mb_strtolower( $row[ $quickSearchColumn ] ), mb_strtolower( trim( \IPS\Request::i()->quicksearch ) ) ) !== FALSE;
            } );

            // HERE


Link to comment
Share on other sites

12 hours ago, bfarber said:

Can you please clarify how I can see this (new) concern in action? When I use the SQL toolbox as an example, pagination seems to work normally.


20 hours ago, newbie LAC said:

Your fix broke some my custom tables.

I found bug during development application

Since you don't like custom code I ofund example (sql toolbox) in the Suite

For this I couldn't find code in the Suite

Link to comment
Share on other sites

15 hours ago, bfarber said:

Ok if you're not seeing an example in the Suite, can you at least outline/clarify what the new issue is that is occurring? Why does moving those lines up as you suggest resolve the problem? We may be able to test a quick contrived example that way.


I use some API


The limit is from 10 to 25. Default is 10

Output is

total: 250

results: list of items

I can't get more than 25 items. But I can use offset


The table 

$limit = 25;
$page = (isset(\IPS\Request::i()->page) and (\intval(\IPS\Request::i()->page) > 0)) ? \IPS\Request::i()->page : 1;
$offset = ($limit * ($page - 1));

$data = array(
	'results' => array(),
	'total' => 0,

	$data = \IPS\Http\Url::external('https://domain.tld/api')
				'k' => 'val',
				'limit' => 25,
				'offset' => $offset,
catch (\Exception $e) {}

$table = new \IPS\Helpers\Table\Custom($data['results'], $url);

$table->limit = $limit;
$table->pages = ceil($data['total'] / $limit);

250/25 = 10 pages

With your fix

		$this->count = \count( $rows );
		$this->pages = ceil( $this->count / $this->limit );

$this->count = \count( $rows ); // 25 (I pass 25 items)

$this->pages = ceil(25 / 25 ); // 1 page

Since I don't use quick search move the code inside condition resolve my issue

Edited by newbie LAC
Link to comment
Share on other sites

  • 2 weeks later...

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy