A Zayed Posted December 17, 2019 Share Posted December 17, 2019 I'm trying to show 2 tables in the same page, everything goes fine except for the pagination part, table reloads without changing contents... Even I use different paginationKey and different sortKey for both tables, but pagination is broken, is it a bug? or am I missing something? Code: /* First Table */ $table_1 = new \IPS\Helpers\Table\Db('first_table', \IPS\Request::i()->url(), array() ); $table_1->include = array( 'col1', 'col2', 'col3'); $table_1->mainColumn = 'col1'; $table_1->parsers = array( 'col2' => function ($val, $row) { return \IPS\DateTime::ts($val); } ); $table_1->sortBy = $table_1->sortBy ?: 'col2'; $table_1->sortDirection = $table_1->sortDirection ?: 'desc'; $table_1->limit = 5; $table_1->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' ); $table_1->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'table' ); $table_1->paginationKey = 'firstTablePage'; $table_1->resortKey = 'firstTableResort'; /* Second Table */ $table_2 = new \IPS\Helpers\Table\Db('second_table', \IPS\Request::i()->url(), array() ); $table_2->include = array( 'col1', 'col2', 'col3'); $table_2->mainColumn = 'col1'; $table_2->parsers = array( 'col2' => function ($val, $row) { return \IPS\DateTime::ts($val); } ); $table_2->sortBy = $table_2->sortBy ?: 'col2'; $table_2->sortDirection = $table_2->sortDirection ? : 'desc'; $table_2->limit = 5; $table_2->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' ); $table_2->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'table' ); $table_2->paginationKey = 'secondTablePage'; $table_2->resortKey = 'secondTableResort'; return \IPS\Theme::i()->getTemplate( 'tempGroup', 'temp' )->browse( (string) $table_1, (string) $table_2 ); Link to comment Share on other sites More sharing options...
Adriano Faria Posted December 17, 2019 Share Posted December 17, 2019 Does your table template has the params? I had this issue yesterday. It was: <div data-role="tablePagination"> {template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit"} </div> When should be: <div data-role="tablePagination"> {template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit, TRUE, $table->getPaginationKey()"} </div> And: <div data-baseurl='{$table->baseUrl}' data-resort='{$table->resortKey}' data-controller='core.global.core.table{{if $table->canModerate()}},core.front.core.moderation{{endif}}'> when should be: <div data-baseurl='{$table->baseUrl}' data-resort='{$table->resortKey}' data-controller='core.global.core.table' {{if $table->getPaginationKey() != 'page'}}data-pageParam='{$table->getPaginationKey()}'{{endif}}> A Zayed 1 Link to comment Share on other sites More sharing options...
A Zayed Posted December 17, 2019 Author Share Posted December 17, 2019 7 minutes ago, Adriano Faria said: Does your table template has the params? I had this issue yesterday. It was: <div data-role="tablePagination"> {template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit"} </div> I'm using the core admin tables: <div data-role="tablePagination" class='ipsSpacer_bottom'> {template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit"} </div> Link to comment Share on other sites More sharing options...
Adriano Faria Posted December 17, 2019 Share Posted December 17, 2019 You can see it’s missing the paginationKey in your template. Compare with what I just posted. Missing because it’s not usual to use 2 tables in same page. I had to use my own templates and add what was missing. Working fine now. A Zayed 1 Link to comment Share on other sites More sharing options...
A Zayed Posted December 17, 2019 Author Share Posted December 17, 2019 Thanks Adriano, I used own custom table template rather than core admin templates... Link to comment Share on other sites More sharing options...
Solution DawPi Posted December 17, 2019 Solution Share Posted December 17, 2019 system/Helpers/Table/Table.php /** * @brief Pagination parameter */ protected $paginationKey = 'page'; Daniel F and A Zayed 2 Link to comment Share on other sites More sharing options...
Daniel F Posted December 17, 2019 Share Posted December 17, 2019 7 minutes ago, DawPi said: system/Helpers/Table/Table.php /** * @brief Pagination parameter */ protected $paginationKey = 'page'; This;) You could also use unique urls, that's what I was using all the time. The issue is that you can't use the same url for both tables. ( I guess that's probably even the better solution, but the other should also work) $table_1 = new \IPS\Helpers\Table\Db('first_table', \IPS\Request::i()->url(), array() ); A Zayed 1 Link to comment Share on other sites More sharing options...
A Zayed Posted December 17, 2019 Author Share Posted December 17, 2019 8 minutes ago, DawPi said: system/Helpers/Table/Table.php /** * @brief Pagination parameter */ protected $paginationKey = 'page'; Yea, got it Link to comment Share on other sites More sharing options...
Adriano Faria Posted December 17, 2019 Share Posted December 17, 2019 @A Zayed is properly using different paginationKey and resortKey in both tables so I'm not sure why indicate it here; it's in his first post. The issue here was the core template, which hasn't the latest 2 parameters in pagination template and also missing the data-pageParam in the table div. 22 minutes ago, Daniel F said: The issue is that you can't use the same url for both tables. Yes, you can. I use it here and on a plugin developed yesterday, where I noticed the missing stuff in templates: /* Featured Images */ $featured = new \IPS\gallery\Image\Table( 'IPS\gallery\Image', \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ), array( array( 'image_feature_flag=?', 1 ) ) ); $newest = new \IPS\gallery\Image\Table( 'IPS\gallery\Image', \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ) ); All comes down to the paginationKey and resortKey. Link to comment Share on other sites More sharing options...
Adriano Faria Posted February 22, 2022 Share Posted February 22, 2022 (edited) On 12/17/2019 at 5:51 PM, Adriano Faria said: Does your table template has the params? I had this issue yesterday. It was: <div data-role="tablePagination"> {template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit"} </div> When should be: <div data-role="tablePagination"> {template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit, TRUE, $table->getPaginationKey()"} </div> And: <div data-baseurl='{$table->baseUrl}' data-resort='{$table->resortKey}' data-controller='core.global.core.table{{if $table->canModerate()}},core.front.core.moderation{{endif}}'> when should be: <div data-baseurl='{$table->baseUrl}' data-resort='{$table->resortKey}' data-controller='core.global.core.table' {{if $table->getPaginationKey() != 'page'}}data-pageParam='{$table->getPaginationKey()}'{{endif}}> Hello, Could you please consider to add the above to the core / admin / table template so I can use pagination (paginationKey) in my tables? In this case I have two tables and pagination doesn't work: Reason: to make pagination work now, I have to copy the entire template and add $table->getPaginationKey() it on it to pagination works. Thank you. Edited February 22, 2022 by Adriano Faria Link to comment Share on other sites More sharing options...
Recommended Posts