我尝试过滤数据时出现 Drupal 分页计数问题

Drupal pagination count issue while i try to filter the data

$table_sort = $query->extend('TableSort')->orderByHeader($header);    
$pager = $table_sort->extend('PagerDefault')->limit($pagerLimit); 
$result = $pager->execute();

我使用此代码进行分页,在我使用过滤器选项之前一切正常。 页面导航 link 可见,即使我只有一条来自按 ID 筛选的记录。

For example:
By default i have 100 records in table,so we can see page navigation link,its good.

问题是当我尝试单独按 id 过滤记录时。 我只有一条与给定 ID 匹配的记录,但现在分页 link 仍然可见。

$countQuery = $query;
$result = $query->execute();
$Totalcount = $result->rowCount();
$page = pager_default_initialize($Totalcount,$pagerLimit);