-1

请注意,此问题专门针对 QCubed PHP 框架的 QDataGrid 功能。QDataGrid的API 文档没有描述任何回答这个问题的特性。QCubed示例站点也没有解决方案。

问题:

有时 QDataGrid 有一百多个页面。有没有办法跳转到多页数据网格中的特定页面?

例如,有一个 167 页的 QDataGrid。QPaginator 仅显示:

上一页 | 1 2 3 4 5 6 7 8 ... 167 | 下一个

所以如果用户想去第100页,他必须做很多点击。(我知道可以对 QDataGrid 进行过滤和排序,但有时这些帮助不大)。

我正在考虑添加一个“跳转到页面”QTextbox,但是我如何告诉 QDataGrid 到文本框中指定的页面?

4

3 回答 3

1

你可以在你的代码中使用这个分页来获得它

    $this->auctionData = new QDataGrid($this);
    $this->auctionData->CssClass = 'table table-striped';
    $this->auctionData->UseAjax = true;
    $this->auctionData->Paginator = new QPaginator($this->auctionData);
    $this->auctionData->ItemsPerPage = 5;
    $this->auctionData->SetDataBinder('BindDataGrid_ExistingAuctions', $this);

在 SetDataBinder 中,您调用该函数。

public function BindDataGrid_ExistingAuctions(){
  $intCfglaneandrun = array();
  $intCfglaneandrun = // your array goes here;

        $this->auctionData->TotalItemCount = count($intCfglaneandrun);
        $this->auctionData->DataSource = $intCfglaneandrun;

}

TotalItemCount 采用分页和迭代中使用的计数,数据源将具有可以在数据网格中显示的数据。

于 2017-02-21T06:45:23.420 回答
0

如果您的意思是从 UI 角度来看,分配一个 Paginator,然后在网页上显示 Paginator。请参阅 qcu.be 上有关数据网格的示例。

在内部,您可以在数据绑定器中通过添加具有正确偏移量和所需页面大小的 QQ::Limit 子句来执行此操作。

于 2015-01-14T19:30:03.380 回答
0

我终于找到了一种使用 qcubed 的方法,也许它可以在将来帮助某人。基本上,我只是在 Form_Create() 函数中添加了一个 QIntegerTextBox 和一个 QButton,并且我添加了一个动作来为 QDataGrid 的 Paginator->PageNumber 属性设置一个值。像这样:

protected function Form_Create() {
        parent::Form_Create();

        // Instantiate the Meta DataGrid
        $this->dtgSignatories = new SignatoryDataGrid($this);

        // Style the DataGrid (if desired)

        // Add Pagination (if desired)
        $this->dtgSignatories->Paginator = new QPaginator($this->dtgSignatories);
        $this->dtgSignatories->ItemsPerPage = __FORM_DRAFTS_FORM_LIST_ITEMS_PER_PAGE__;

// more code here
// to add columns to the datagrid

        // page box
        $this->intPage = new QIntegerTextBox($this);
        $this->intPage->Width = 50;
        $this->intPage->AddAction(new QEnterKeyEvent(), new QServerAction('btnGo_Click'));

        // "go" button
        $this->btnGo = new QButton($this);
        $this->btnGo->Text = QApplication::Translate('Go');
        $this->btnGo->AddAction(new QClickEvent(), new QAjaxAction('btnGo_Click'));
        $this->btnGo->AddAction(new QClickEvent(), new QServerAction('btnGo_Click'));
        $this->btnGo->CausesValidation = true;
}

protected function btnGo_Click($strFormId, $strControlId, $strParameter) {
        $count = Signatory::CountAll();
        $pages = ceil($count / __FORM_DRAFTS_FORM_LIST_ITEMS_PER_PAGE__);
        if ($this->intPage->Text < 1) {
                $this->intPage->Text = 1;
        } elseif ($this->intPage->Text > $pages) {
                $this->intPage->Text = $pages;
        }
        $this->dtgSignatories->Paginator->PageNumber = $this->intPage->Text;
        $this->dtgSignatories->Refresh();
}
于 2015-01-20T11:46:50.720 回答