I
I
Ivan Anikin2021-07-05 10:12:12
1C-Bitrix
Ivan Anikin, 2021-07-05 10:12:12

How to call pagination for your orm object in the site admin?

I'm making a custom page in the admin panel.
Can't get pagination to work.
Page Code

<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
$adminPage->Init();
$adminMenu->Init($adminPage->aModules);
if(empty($adminMenu->aGlobalMenu))
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
$APPLICATION->SetAdditionalCSS("/bitrix/themes/".ADMIN_THEME_ID."/index.css");
$APPLICATION->SetTitle("Заголовок страницы");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");

$nav = new \Bitrix\Main\UI\AdminPageNavigation("my_table_id");
$cultureList = Custom\Orm\MyLogTable::getList([
        'order'=>['ADD_DATE_TIME'=>'DESC'],
    'count_total' => true,
    'limit' => $nav->getLimit(),
    'offset' => $nav->getOffset()]);
$nav->setRecordCount($cultureList->getCount());
?>
    <table class="adm-list-table">
        <tbody>
        <? while ($item = $cultureList->fetch() ) {?>
           <!--Карточки объектов-->
        <?}?>
        </tbody>
    </table>
<?
$APPLICATION->IncludeComponent(
    "bitrix:main.pagenavigation",
    "admin",
    array(
        "NAV_OBJECT" => $nav,
        "TABLE_ID" => "my_table_id",
        "SEF_MODE" => "N",
        "SHOW_COUNT" => "Y",
    ),
    false
);
require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin.php");
?>

As a result, I see Pagination and even the number of pages is correct, but it does not work. When clicked, it gives a js error.
Uncaught ReferenceError: my_table_id is not defined at

HTMLAnchorElement.onclick
60e2b75c68eba986234309.png
60e2b78df3278566810661.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Anikin, 2021-07-05
@randomizex

How "So-so" solution helped to change the template to '.default' and "SEF_MODE" => "N"
and the number of elements on the page can be controlled via $nav->setPageSize().

T
tgarl, 2021-07-05
@tgarl

I also made calls

$nav = new \Bitrix\Main\UI\PageNavigation("nav-more-notice");
$nav->allowAllRecords(true)
   ->setPageSize(15)
   ->initFromUri();

and remove "TABLE_ID" => "my_table_id" in the navigation,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question