Please note that this question is specifically for the QDataGrid feature of the QCubed PHP framework. The API documentation for QDataGrid does not describe any feature that answers this question. The QCubed samples site also doesn't have a solution for this.
Question:
Sometimes a QDataGrid has more than a hundred pages. Is there a way to jump to a specific page in a multi-page datagrid?
For example, there's a QDataGrid with 167 pages. The QPaginator only shows:
Previous | 1 2 3 4 5 6 7 8 ... 167 | Next
So if the user wants to go to page 100, he has to do a lot of clicks. (I know the QDataGrid can be filtered and sorted, but there are times when those are of little help).
I'm thinking of adding a "jump to page" QTextbox, but how would I tell QDataGrid to the page specified in the textbox?
I finally found a way to do this using qcubed, maybe it can help someone in the future. Basically, I just added a QIntegerTextBox and a QButton in the Form_Create() function, and I added an action to set a value for the QDataGrid's Paginator->PageNumber property. Like this:
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();
}