Help: Tutorial on using Panel, QDataGrid, and QAutocomplete

thread: 2 messages  |  last: a year ago  |  started: wednesday, february 24, 2010, 2:32 pm pst


#1  |  kingwithin (San Francisco, CA) United States of America
Wednesday, February 24, 2010, 2:32 PM PST

This tutorial is designed to show how a user can:

  • enter a value in a form textbox
  • the textbox will use a server-side Autocomplete
  • when the item is added, it will update using ajax the QDataGrid.

Creating the text fields in a panel


class TargetForm extends QForm {

    protected $pnlAddTarget;

    protected function Form_Create() {

        $this->pnlAddTarget = new QPanel($this);
        $this->pnlAddTarget->Position = QPosition::Relative;
        $this->pnlAddTarget->CssClass = 'pnlAddTarget';
        $this->pnlAddTarget->Template = __TEMPLATES__ . "/addnewtarget.tpl.php";

This creates a QPanel which is displayed inside the template with:

<?php $this->pnlAddTarget->Render(); ?>    

the addnewtarget.tpl.php contains the controls for the text field and the button:

<?php
$this
->txtNewTarget->RenderWithError();

$this->btnAddTarget->Render();
?>

Define the controls for autocompletion

        /* Define control as autocomplete control */
        $this->txtNewTarget = new QAutoCompleteTextBox($this);

        // QAutoCompleteTextBoxEvent Action is needed for Ajax respond
        $this->txtNewTarget->UseAjax = true; 
                 
//Define events around the text box

$this->txtNewTarget->AddAction(new QAutoCompleteTextBoxEvent(), new QAjaxAction('txtNewTarget_Change', $this->pnlWaitIcon));

$this->txtNewTarget->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnAddTarget_Click'));

$this->txtNewTarget->AddAction(new QEnterKeyEvent(), new QTerminateAction());

Problems/Questions

Alright, we have defined the textfield with the QAutoCompleteTextBox controller.  That is found in another file.

But I am using the AddActioni and trying to define it for keyevents, but not sure if this is correct or how to explain it properly.

Controller for the Button in the QPanel

        $this->btnAddTarget = new QButton($this->pnlAddTarget,"btnAddTarget");
        $this->btnAddTarget->CssClass =  "button";
        $this->btnAddTarget->Text = "Add Account to Targets";

This is how a button that is contained in a panel is defined and the text and css class assigned.

$this->btnAddTarget->AddAction(new QClickEvent(), new QAjaxAction('btnAddTarget_Click'));

Here is the actual ajax action, again, not clear how to explain or document this.

So this is part I but need some comments to help explain how this is working or not working properly.

#2  |  kentpachi (France, EU) France
Monday, March 1, 2010, 1:19 AM PST

Thanks for this tutorial dude



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.