0

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?

J0e3gan
  • 8,740
  • 10
  • 53
  • 80
  • 1
    What have you tried or found through research? To narrow your question, edit it with where your efforts have landed and where you are specifically stuck. – J0e3gan Jan 15 '15 at 03:52
  • 1
    @whoever had put this on hold - this is not an easy question considering the framework and is not too broad (also it seems the asker has edited it). If possible, please remove the hold. – Vaibhav Kaushal Jan 15 '15 at 05:14
  • 1
    Added more details, including research efforts made. Please unhold. – neurotic imbecile Jan 15 '15 at 15:38
  • Added more details, including research efforts made. Please unhold: @J0e3gan. Thanks. – neurotic imbecile Jan 15 '15 at 17:07
  • Added more details, including research efforts made. Please unhold: @andy . Thanks in advance. – neurotic imbecile Jan 15 '15 at 17:07
  • Added more details, including research efforts made. Please unhold: @luc-m. Thanks in advance. – neurotic imbecile Jan 15 '15 at 17:08
  • Added more details, including research efforts made. Please unhold: @talonmies. Thanks in advance. – neurotic imbecile Jan 15 '15 at 17:08
  • Added more details, including research efforts made. Please unhold: @display-name-is-missing . Thanks in advance. – neurotic imbecile Jan 15 '15 at 17:09
  • Added more details, including research efforts made. Please unhold: @winterblood. Thanks in advance. – neurotic imbecile Jan 15 '15 at 17:09
  • No need to repeat comments. :) I did not vote to put the question on hold; you can see who did in the on-hold notice; but edits have improved the question greatly: I followed with another round of edits and voted to reopen the question. – J0e3gan Jan 15 '15 at 17:43
  • Sorry about the repeated comments. The "comments" facility allow the mention of only one person per comment, so I had to make 1 comment to mention each person so they would all be notified of the changes, and hopefully get this question unheld. – neurotic imbecile Jan 15 '15 at 17:47
  • @neuroticimbecile I think there was a plugin for this same thing. Or if you want to, you can override the defaul paginator class and make it work like that. In case you are able to build it as a part of paginator itself (by modifying) then do that and send a pull request. – Vaibhav Kaushal Jan 16 '15 at 09:14

3 Answers3

1

U can use this pagination in your code to get that

    $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);

In SetDataBinder u call the function.

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

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

}

the TotalItemCount takes the count which is used in the pagination and iteration and the Datasource will have the data which can be shown in the datagrid.

J. Chomel
  • 8,193
  • 15
  • 41
  • 69
0

If you mean from a UI perspective, assign a Paginator, and then show the Paginator on the web page. See the Examples on datagrids at qcu.be.

Internally, you would do that in your data binder by adding a QQ::Limit clause with the correct offset and size of the page that you want.

spekary
  • 408
  • 5
  • 10
0

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();
}