QCubed - A PHP5 rapid development MVC framework.
Home  |  Updates

QDataGrid

IE Problems with DataGrid Paging and Sorting

I just upgraded from 1.1 to 2.2.1

Everything is working fine for the most part. However, in IE 10, the DataGrid is not paging or sorting. Clicking on the links does not produce a javascript error that I can see, but absolutely nothing happens. I'm using Ajax to do it.

The exact same page works perfectly in Chrome and FF. Any clues as to what needs to be updated?

When I set UseAjax to false, works perfectly in IE.

QDatagrid sorting issue

Hello QCubed,

I use the CssClass - property and css - style to change text-alignment of QDatagrid Columns,
works OK, but after clicking the sort control in the datagrid header, the alignment ist lost

see attached pics

code (template file) is

...
  $this->dtgProducts->GetColumn(2)->Wrap       = false;
  $this->dtgProducts->GetColumn(3)->Name       = 'Wert';
  $this->dtgProducts->GetColumn(3)->CssClass   = 'decimal';
  // $this->dtgProducts->GetColumn(3)->Width      = '90px';
  $this->dtgProducts->GetColumn(3)->Wrap       = false;
  $this->dtgProducts->GetColumn(4)->Name       = 'Anzahl';
  $this->dtgProducts->GetColumn(4)->CssClass   = 'centered';
  // $this->dtgProducts->GetColumn(4)->Width      = '90px';
  $this->dtgProducts->GetColumn(4)->Wrap       = false;
  $this->dtgProducts->GetColumn(5)->Name       = 'Datum Von';
  $this->dtgProducts->GetColumn(5)->Width      = '110px';
  // $this->dtgProducts->GetColumn(5)->CssClass   = 'datetime';
  $this->dtgProducts->GetColumn(5)->Wrap       = false;
  $this->dtgProducts->GetColumn(6)->Name       = 'Datum Bis';
  $this->dtgProducts->GetColumn(6)->Width      = '105px';
  // $this->dtgProducts->GetColumn(6)->CssClass   = 'centered';
  $this->dtgProducts->GetColumn(6)->Wrap       = false;
  $this->dtgProducts->GetColumn(7)->Name       = 'Anbieter';
...

css looks like

...
/* Non-Default Textboxes */
.decimal {
   text-align: right;
   padding-right: 20px;
/*   width: auto;*/
}
.centered {
   text-align: center;
   padding-right: 20px;
/*   width: auto;*/
}
.datetime {
   text-align: left;
   padding-right: 20px;
/*   width: auto;*/
}
...

maybe this is a bug (?)

any suggestions / comments

best regards

norbert

setting parent control on Qdatagrid implementing of Qpanel

Hi guys,
Do hope anybody can help Me.

I get this error :
Fatal error: Call to undefined method Dashboard::Id_render() in D:\xampp\htdocs\simpp\framework\includes\qcubed\_core\base_controls\QDataGridBase.class.php(453) : eval()'d code on line 1.
I tried to implement Qpanel taken from Ajaxdashboard of example.
I have Dashboard class extends of QForms that call every class on my app.
I have User class to be called first time (as example, latter it will call another dashboard class) when my app load.
In User class, I have Modified QDataGrid Class extends QForm for my app purpose.
when use this code for adding Id of user to be rendered as column on datagrid.

$this->colKode=new QDataGridColumn('Id','<?= $_ITEM->Id ?>');

its works fine. then I want to styling that Id using function on Form, so the code as below :
$this->colKode=new QDataGridColumn('Id','<?= $_FORM->Id_render($_ITEM) >');

public function Id_Render($obj){
   return $obj->Id ; // just for sample
           
}

and I get this error :
Call to undefined method Dashboard::Id_render()
as I know, its tell Me that there is no Id_render() function on Dashboard Form.
Does anybody know how to fix this error ?
I though the error about how to set parent control from dashboard class to User class.

this is my modified QDatagrid

<?php
class DSMGrid extends QForm {
    public
$dtgList;
    public
$RecsPerPage=25;
    public
$colNo;
    public
$colSelect;
    public
$colSelect2;
    public
$strPrefix;
   
    public function
__construct($objParentObject,$objDataBinder,$isColSelect=true,$strPrefix='',$isColNo=true,$type=1){
//        parent::__construct($objParentObject, $strControlId);
//            $this->SetDataBinder('MetaDataBinder', $this);
//            $this->UseAjax = true;
        // Keterangan Parameter
        // $objDataBinder : digunakan untuk set DataBinding/datasource dari datagrid yg sedang di set
        // $isColSelect (default True ) : digunkan untuk render col select sebelah kanan setelah col number
        // $strPrefix : ?????
        // $type : 1 --> Checkbox menggunakan checkselected
        //         2 --> RadioButton menggunakan checkselected2
       
$this->strPrefix=$strPrefix;
       
// Setup DataGrid
       
$this->dtgList = new QDataGrid($objParentObject,"dgapbdstruktur");
       
$this->dtgList->CellSpacing = 0;
       
$this->dtgList->CellPadding = 4;
       
$this->dtgList->BorderStyle = QBorderStyle::Solid;
       
$this->dtgList->BorderWidth = 1;
       
$this->dtgList->GridLines = QGridLines::Both;
       
$this->dtgList->Width = '100%';
       
       
// Datagrid Paginator
       
$this->dtgList->Paginator = new QPaginator($this->dtgList);
       
$this->dtgList->ItemsPerPage =$this->RecsPerPage;
       
// Specify Whether or Not to Refresh using Ajax
       
$this->dtgList->UseAjax = true;
       
// Specify the local databind method this datagrid will use
       
$this->dtgList->SetDataBinder($objDataBinder,$objParentObject);
       
// Setup Default Column
       
$this->dtgList->CssClass="table-list";
       
//row style
       
$objStyle = $this->dtgList->RowStyle;
       
$objStyle->CssClass = 'row0';
       
$objStyle = $this->dtgList->AlternateRowStyle;
       
$objStyle->CssClass = 'row1';
        if(
$isColNo) $this->colNo_Create();
       
//if($isColSelect) $this->colSelect_Create();
       
       
if($isColSelect) {
           if (
$type == 1) $this->colSelect_Create();
           else
               
$this->colSelect2_Create();
        }
       
    }
   
    public function
Checkbox_Create($strControlId){
       
$chkSelected = new QCheckBox ($this->dtgList, $strControlId);
        return
$chkSelected;
    }
     public function
Rbutton_Create($strControlId){
       
$optSelected = new QRadioButton($this->dtgList, $strControlId);
        return
$optSelected;
    }
    public function
colSelect_Create(){
       
$method='$_FORM->'.$this->strPrefix.'chkSelected_Render($_ITEM)';
       
$colCheck ='<input type="checkbox" id="checkall'.$this->strPrefix.'" onclick="CheckIt('."'".$this->strPrefix."'".');">';
       
$this->colSelect=new QDataGridColumn($colCheck , "<?= $method ?>
");
/*$this->colSelect = new QCheckBoxColumn(QApplication::Translate('Select All'), $this->dtgList);
$this->colSelect->SetCheckboxCallback($this, 'chkSelected1_Render');  */
$this->colSelect->HtmlEntities = false;
$this->colSelect->VerticalAlign='top';
$this->colSelect->HorizontalAlign="center";
$this->colSelect->Width="1%";

$this->dtgList->AddColumn($this->colSelect);
}
     public function colSelect2_Create(){
        $method='$_FORM->'.$this->strPrefix.'optSelected_Render($_ITEM)';
        $this->colSelect2=new QDataGridColumn('Pilihan',  "<?= $method ?>");
        $this->colSelect2->HtmlEntities = false;
        $this->colSelect2->VerticalAlign='top';
        $this->colSelect2->HorizontalAlign="center";
        $this->colSelect2->Width="1%";
       
        $this->dtgList->AddColumn($this->colSelect2);
    }
public function AddColumn($col){
$this->dtgList->AddColumn($col);
}
public function Refresh(){
$this->dtgList->Refresh();
}
protected function colNo_Create(){
$method='$_FORM->'.$this->strPrefix.'RowNumber_Render()';
$this->colNo=new QDataGridColumn('No.', "<?= $method;?>");
$this->colNo->VerticalAlign='top';
$this->colNo->Width="1%";
$this->dtgList->AddColumn($this->colNo);
}



public function __set($strName, $mixValue) {
switch ($strName) {
case 'Prefix':
$this->strPrefix=$mixValue;
break;
case 'TotalItemCount':
$this->dtgList->TotalItemCount=$mixValue;
break;
case 'OrderByClause':
$this->dtgList->OrderByClause=$mixValue;
break;
case 'LimitClause':
$this->dtgList->LimitClause=$mixValue;
break;
case 'DataSource':
$this->dtgList->DataSource=$mixValue;
break;
case 'ItemsPerPage':
$this->dtgList->ItemsPerPage=$mixValue;
break;
case 'PageNumber':
return $this->dtgList->PageNumber=$mixValue;

}
}
public function __get($strName) {
switch ($strName) {
case 'Prefix':
return $this->strPrefix;
break;
case 'TotalItemCount':
return $this->dtgList->TotalItemCount;
break;
case 'Render':
return $this->dtgList->Render();
break;
case 'OrderByClause':
return $this->dtgList->OrderByClause;
break;
case 'LimitClause':
return $this->dtgList->LimitClause;
break;
case 'PageNumber':
return $this->dtgList->PageNumber;
break;
case 'ItemsPerPage':
return $this->dtgList->ItemsPerPage;
break;
}
}

}
?>

this is my Dashboard Class
<?php
   
require_once('framework/qcubed.inc.php');
    include (
'dsmcontrols/DSMGridControl.class.php');

   
$objDirectory = opendir(__CLASSDIR__);
   
$strClassNameArray = array();
    while (
$strFile = readdir($objDirectory)) {
      
        if (
$intPosition = strpos($strFile, 'php')) {
             require(
__CLASSDIR__ . '/' .$strFile);
        }
    }
   
asort($strClassNameArray);


    class
Dashboard extends QForm {
        protected
$lstClassNames;

        protected
$lblTitle;
        protected
$pnlList;
        protected
$pnlEdit;
       
// menu
       
protected $btnMenuUser;
        protected
$btnMenuD1;
        protected
$objWaiticonMenu;

        protected function
Form_Create() {
           
$this->lblTitle = new QLabel($this);
           
$this->lblTitle->Text = 'User List';

           
$this->pnlList = new QPanel($this, 'pnlList');
           
$this->pnlList->AutoRenderChildren = true;
           
$this->pnlList->Visible = true;

           
$this->pnlEdit = new QPanel($this, 'pnlEdit');
           
$this->pnlEdit->AutoRenderChildren = true;

           
// first class to be called when app start up
           
$strClassName = 'UserListPanel';
           
$objNewPanel = new $strClassName($this->pnlList, 'SetEditPane', 'CloseEditPane');

           
// create wait icon
           
$this->objWaiticonMenu = new QWaitIcon($this);
           
$this->objWaiticonMenu->Text = 'Sedang load halaman';

           
// create menu
           
$this->menu_create();


        }
        protected function
menu_create(){
           
$this->btnMenuUser = new QLabel($this);
           
$this->btnMenuUser->Text = QApplication::Translate('Daftar User') ;
           
$this->btnMenuUser->AddAction(new QClickEvent(), new QAjaxAction('btnUser_Click',$this->objWaiticonMenu));
           
           
$this->btnMenuD1 = new QLabel($this);
           
$this->btnMenuD1->Text = QApplication::Translate('Dashboard1') ;
           
$this->btnMenuD1->AddAction(new QClickEvent(), new QAjaxAction('btnD1_Click',$this->objWaiticonMenu));
           
        }
       
// action for menu click
       
protected function btnUser_Click($strFormId, $strControlId, $strParameter) {
           
$this->pnlList->RemoveChildControls(true);
           
$strClassName = 'UserListPanel';
           
$objNewPanel1 = new $strClassName($this->pnlList, 'SetEditPane', 'CloseEditPane');
        }

        protected function
btnD1_Click($strFormId, $strControlId, $strParameter) {
           
$this->pnlList->RemoveChildControls(true);
           
$strClassName = 'StrukturApbdListPanel';
           
$objNewPanel2 = new $strClassName($this->pnlList, 'SetEditPane', 'CloseEditPane');
        }

       
/**
        * This Form_Validate event handler allows you to specify any custom Form Validation rules.
        * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
        */
       
protected function Form_Validate() {
           
// By default, we report that Custom Validations passed
           
$blnToReturn = true;

           
// Custom Validation Rules
            // TODO: Be sure to set $blnToReturn to false if any custom validation fails!

           
$blnFocused = false;
            foreach (
$this->GetErrorControls() as $objControl) {
               
// Set Focus to the top-most invalid control
               
if (!$blnFocused) {
                   
$objControl->Focus();
                   
$blnFocused = true;
                }

               
// Blink on ALL invalid controls
               
$objControl->Blink();
            }

            return
$blnToReturn;
        }

        public function
RefreshParent(){
           
$this->pnlList->Refresh();
        }
        public function
CloseEditPane($blnUpdatesMade) {
           
// Close the Edit Pane
           
$this->pnlEdit->RemoveChildControls(true);
           
$this->pnlEdit->Visible = false;
           
$this->pnlList->Visible = true;
           
// If updates were made, let's "brute force" the updates to the screen by just refreshing the list pane altogether
           
if ($blnUpdatesMade)
               
$this->pnlList->Refresh();
        }

        public function
SetEditPane(QPanel $objPanel = null) {
           
$this->pnlEdit->RemoveChildControls(true);
            if (
$objPanel) {
               
$objPanel->SetParentControl($this->pnlEdit);
               
$this->pnlEdit->Visible = true;
//                $this->pnlList->Visible = false;
           
} else {
               
$this->pnlEdit->Visible = false;
            }
        }


    }

   
Dashboard::Run('Dashboard','templates/dashboard.tpl.php');
    require_once(
'footer.php');

?>

and this is my User class
<?php
   
/**
     * This is the abstract Panel class for the List All functionality
     * of the User class.  This code-generated class
     * contains a datagrid to display an HTML page that can
     * list a collection of User objects.  It includes
     * functionality to perform pagination and sorting on columns.
     *
     * To take advantage of some (or all) of these control objects, you
     * must create a new QPanel which extends this UserListPanelBase
     * class.
     *
     * Any and all changes to this file will be overwritten with any subsequent re-
     * code generation.
     *
     * @package My QCubed Application
     * @subpackage Drafts
     *
     */
   
class UserListPanel extends QPanel {
       
// Local instance of the Meta DataGrid to list Users
        /**
         * @var UserDataGrid
         */
       
public $dtgUsers;
        public
$colKode;

       
// Other public QControls in this panel
        /**
         * @var QButton CreateNew
         */
       
public $btnCreateNew;
        public
$btnCoba;
       
/**
         * @var QControlProxy ProxyEdit
         */
       
public $pxyEdit;

       
// Callback Method Names
        /**
         * @var string SetEditPanelMethod
         */
       
protected $strSetEditPanelMethod;
       
/**
         * @var string CloseEditPanelMethod
         */
       
protected $strCloseEditPanelMethod;

        public function
__construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) {
           
// Call the Parent
           
try {
               
parent::__construct($objParentObject, $strControlId);
            } catch (
QCallerException $objExc) {
               
$objExc->IncrementOffset();
                throw
$objExc;
            }

           
// Record Method Callbacks
           
$this->strSetEditPanelMethod = $strSetEditPanelMethod;
           
$this->strCloseEditPanelMethod = $strCloseEditPanelMethod;

           
// Setup the Template
           
$this->Template = 'templates/UserListPanel.tpl.php';

           
// Instantiate the Meta DataGrid
           
$this->dtgUsers = new UserDataGrid($this);

           
// Style the DataGrid (if desired)
           
$this->dtgUsers->CssClass = '';
           
$this->dtgUsers->AlternateRowStyle->CssClass = 'alternate';

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

           
// Use the MetaDataGrid functionality to add Columns for this datagrid

            // Create an Edit Column
           
$this->pxyEdit = new QControlProxy($this);
           
$this->pxyEdit->CssClass = 'modalopen';
           
$this->pxyEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEdit_Click'));
           
$this->dtgUsers->MetaAddEditProxyColumn($this->pxyEdit, 'Edit', 'Edit');

           
// Create the Other Columns (note that you can use strings for user's properties, or you
            // can traverse down QQN::user() to display fields that are down the hierarchy)
//            $this->dtgUsers->MetaAddColumn('Id');
            /*$this->colKode=new QDataGridColumn('Id','<?= $_ITEM->Id ?>
');*/
            $this->colKode=new QDataGridColumn('Id','<?= $_FORM->Id_render($_ITEM) ?>');
            $this->dtgUsers->AddColumn($this->colKode);
$this->dtgUsers->MetaAddColumn('Username');
$this->dtgUsers->MetaAddColumn('NamaUser');
$this->dtgUsers->MetaAddColumn('Jabatan');

// Setup the Create New button
            $this->btnCreateNew = new QLabel($this);
            $this->btnCreateNew->HtmlEntities = false;
            $this->btnCreateNew->Text = '<a id="" class="modalopen" href="#modalcontent">Create a New User</a>';
$this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click'));
          
}
        public function Id_Render($obj){
            return $obj->Id ;
           
        }

public function pxyEdit_Click($strFormId, $strControlId, $strParameter) {
$strParameterArray = explode(',', $strParameter);
$objEditPanel = new UserEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0]);

$strMethodName = $this->strSetEditPanelMethod;
$this->objForm->$strMethodName($objEditPanel);
}

public function btnCreateNew_Click($strFormId, $strControlId, $strParameter) {
$objEditPanel = new UserEditPanel($this, $this->strCloseEditPanelMethod, null);
$strMethodName = $this->strSetEditPanelMethod;
$this->objForm->$strMethodName($objEditPanel);
           
}
}
?>

I really appreciate the helps.
best regards,

Ahmad.

Highlight any row using QDatagrid for any specific condition

Hi Friends,

I am using QCubed 2 Framework for my small web app.
I am facing a problem to highlight any row using QDatagrid for a specific condition.

Example: I am using QDatagrid to display list of users from database table "Users". Now in database table, have a field/column say "Status" which contains "Y" or "N" value.
I need a mechanism were "Y" status list will have "Green" background table row and "N" status list will have "Red" background table row.

Please help.

Qdatagrid not refreshed using Opera browser

hi everyone,

just found an issue on using opera browser (please see attachment)

I use a QDatagrid with a QPaginator and as You can see, the contents of the page is not updated when switching to the next page if there are few items then on the previous page.
Refresh is executed when I minimize and maximize the opera window.

Opera is Version 11.61 Build 1250 on WinXP (32).

Using Firefox, IE on same WinXP and Firefox on Linux refresh works.

Any Suggestions

tnx

Norbert

BTW: this is not an urgent problem, I just can convince my users to use Firefox or IE.

QCheckboxColumn Select All - Only selects rendered items

I have inherited a website using the QCubed framework and a complaint from one of the users.

The data is being displayed is a custom class being extended from QDataGrid, and has a column of QCheckBoxColumn. There is also a checkbox in the header to "Select All". When this box is selected, the items on the current tab are selected, but the items on the remaining tabs are not selected. The behavior acts as in this page (http://examples.qcu.be/assets/_core/php/examples/dynamic/qcheckboxcolumn...). To replicate, select the 'select all' box, then move to the second tab. These new items will not be selected.

The request that I got from the user is to have the checkbox select all items over all the tabs. I have attempted a couple solutions that did not work as expected.

One solution that I have come up with is to loop through the elements in the dataset, and set those values to be checked. The downside here is that some elements are not rendered, so it does not affect everything, on the ones that have been viewed. I also attempted to prerender the elements by setting the itemsPerPage to the number in the dataset, then reduce back down to the normal itemsPerPage (10), but rendering several thousand items, this takes too much time to be acceptable.

Can anyone help?

I have looking through the forum attempting to find the solution, but haven't been able to do so. I have found this topic (http://qcu.be/content/qcheckboxcolumn-select-all), but he seems to be having a different issue.

QDatagrid GetFilters restricition

Hey

I came across an error while I tried to use custom datagrid filters with the datagrid column's FilterAddListItem(string, QQCondition) method.

The exception was that it expected a QQConditionComparison whereas I used multiple QQConditionComparisons wrapped in a QQConditionLogical.

So in the QDatagridBase class in the method GetFilters I changed

<?php
if($col->Filter instanceof QQConditionComparison)
{
   
$filters[$col->Name] = $col->Filter;
}
?>

to
<?php
if($col->Filter instanceof QQConditionComparison
|| $col->Filter instanceof QQConditionLogical)
{
   
$filters[$col->Name] = $col->Filter;
}
?>

to see if it works.

It worked correctly and now my question is was that just missed (i.e. should I open a ticket) or is there another reason behind this that I am missing?

Tutorial - Nested QDataGrid The How To?

Hi everyone, as my first contribution to the community of qcubed I will explain and demonstrate how to create a nested QDatagrid.

With a MAster QDatagrid and through a button, usually a '+'to prove they can expand, appear a Child QDataGrid with other content as you can see in the screen_1.jpg attach.

Some preconceptions to consider first are:

- Master QDataGrid should go on the FORM.
- Child must be in QPanel QDataGrid (I like it better to say that the style created as User Controls. NET)
- We must always know who are the children and parents the QDataGrids.
- HtmlEntities in QdataGrid always 'False'. I Expend two days looking for this error =P.

Let's start ...

First we need to create the Master QDataGrid...

<?php
   
// Load the QCubed Development Framework
   
require ('../../qcubed.inc.php');

       
// Load User Controls -> This is the First Child QDataGrid.
        // It be  explian later, at the moment the only you need to know is
        // it was created like a .NET User Control and extends from a QPanel.
       
require (__APP_CONTROLS__ . '/records.summary.php');

       
        class
DomainList extends QForm {

               
// Datagrid List Control for Domains
               
protected $dtgDomains;

               
// This is for refresh the QDataGrid and make appear the childs
                // Datagrid becaouse i use ajax.
               
protected function Form_PreRender() {
                   
parent::Form_PreRender();

                   
$this->dtgDomains->Refresh();
                }

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

                   
// Create the Master DataGrid
                    // I make derived from another QDataGrid but is just for
                    // apply styles css, nothing important

                   
$this->dtgDomains = new DomainGridControl($this);
                   
$this->dtgDomains->SetDataBinder('dtgDomains_Bind');

                   
// Here we start, create our first control a simple toogle
                    // button
                   
$this->dtgDomains->AddColumn(
                            new
QDataGridColumn('','<?= $_FORM->render_btnToggleRecordsSummary($_ITEM) ?>
','HtmlEntities=false', 'Width=1px'));

                    // And some other data columns...
                    $this->dtgDomains->MetaAddColumn(QQN::Domains()->Zone,'Name=Domain',
                            array('OrderByClause' => QQ::OrderBy(QQN::Domains()->Zone),
                                  'ReverseOrderByClause' => QQ::OrderBy(QQN::Domains()->Zone, false))
                           );

                    // Second... we need to create out Child QDataGrid sp put them
                    // hide in a column.
                    $this->dtgDomains->AddColumn(
                            new QDataGridColumn('','<?= $_FORM->render_ucRecordsSummary($_ITEM) ?>','HtmlEntities=false','Width=1px'));
                }

                public function dtgDomains_Bind() {
                    // Bind... nothing important...
                }

                // Function to render our toggle button column
                // As you can see we pass as a parameter the item binded in the
                // row of QDataGrid
                public function render_btnToggleRecordsSummary(Domains $objDomain) {

                    // Create their unique id...
                    $objControlId = 'btnToggleRecordsSummary' . $objDomain->Id;

                    if (!$objControl = $this->GetControl($objControlId)) {

                        // If not exists create our toggle button who his parent
                        // is our master QDataGrid...
                        $objControl = new QButton($this->dtgDomains, $objControlId);
                        $objControl->Text = '+';
                        $objControl->CssClass = 'inputbutton';

                        // Pass the id of the bounded item just for other process
                        // on click event

                        $objControl->ActionParameter = $objDomain->Id;

                        // Add event on click the toogle button
                        $objControl->AddAction(new QClickEvent(), new QAjaxAction('btnToggleRecordsSummary_Click',$this->dtgDomains->WaitIcon));
                    }

                    // We pass the parameter of "false" to make sure the control doesn't render
                    // itself RIGHT HERE - that it instead returns its string rendering result.
                    return $objControl->Render(false);
                }


                // Clicking the toogle button...
                public function btnToggleRecordsSummary_Click($strFormId, $strControlId, $strParameter) {

                    // First get the button himself for change '+' to '-'
                    $srcControl = $this->GetControl($strControlId);

                    $intDomainId = intval($strParameter);

                    // Look for our child QDatagrid if is render...
                    $objControlId = 'ucRecordsSummary' . $intDomainId;
                    $objControl = $this->GetControl($objControlId);

                    if ($objControl) {
                        // Ask if our Child DataGrid is visible...
                        if ($objControl->Visible) {
                            // Make it desapear ...
                            $objControl->Visible = false;
                            $srcControl->Text = '+';
                        } else {
                            // Or make it appear...
                            $objControl->Visible = true;
                            $srcControl->Text = '-';
                        }

                        // Important! Refresh the parent QDataGrid...
                        $this->dtgDomains->Refresh();
                    }                   
                }

                // Ladys and Gentleman... Our Child QDataGrid... =P
                public function render_ucRecordsSummary(Domains $objDomain) {

                    $objControlId = 'ucRecordsSummary' . $objDomain->Id;

                    if (!$objControl = $this->GetControl($objControlId)) {

                        // Create the User Control Child QDataGrid passing the
                        // parent, in this case Master QDataGrid and the unique id.
                        $objControl = new RecordsSummary($this->dtgDomains, $objDomain, $objControlId);

                        //Put invisible at the begging, the toogle button gona do
                        //the job
                        $objControl->Visible = false;
                    }

                    return $objControl->Render(false);
                }
        }

DomainList::Run('DomainList', __APP_VIEW_ACCOUNT__ . '/domain.list.tpl.php');
?>

Well thats all for the Master QDataGrid, at here everythings looks normal uh?

ok here is the Child QDataGrid...

<?php
       
// Load the QCubed Development Framework
       
require_once('../../qcubed.inc.php');

       
// Load User Controls -> Load Other QDataGrids Child of this one
        // This is not awseome? QdataGrid can do everything!!
       
require (__APP_CONTROLS__ . '/a.records.list.php');
        require (
__APP_CONTROLS__ . '/cname.records.list.php');
        require (
__APP_CONTROLS__ . '/mx.records.list.php');
        require (
__APP_CONTROLS__ . '/srv.records.list.php');
        require (
__APP_CONTROLS__ . '/spf.records.list.php');


       
// As you can see thie QDataGrid extends the QPanel not a QForm
       
class RecordsSummary extends QPanel {

               
// QDatagrid Records Summary
               
public $dtgRecordsSummary;

               
// dtgDomains -> this is our Master QDataGrid
               
protected $objParentObject;

               
// Protected Objects
               
protected $objDomain;
           
               
// in the contructor pass the item bounded too just for other
                // process
               
public function __construct($objParentObject, Domains $objDomain, $strControlId = null) {

                    try {
                       
                       
parent::__construct($objParentObject, $strControlId);
                       
                       
// Watch out for template later gonna talk about it,
                        // need a trick to look good.
                       
$this->Template = __APP_CONTROLS__ . '/records.summary.tpl.php';

                       
// Setting local the MAster QDataGrid to refresh on
                        // Saves on the Child DataGrid..
                       
$this->objParentObject = $objParentObject;
                       
$this->objDomain = $objDomain;
                      
                       
// Create the child DataGrid as a simply...QDataGrid
                        // normal
                       
$this->dtgRecordsSummary = new QDataGrid($this);
                       
                       
// Bind him, the normal...
                       
$this->dtgRecordsSummary->SetDataBinder('dtgRecordsSummary_Bind', $this);

                       
// Need another Child QDataGrid? ok add their toogle
                        // button...
                       
$this->dtgRecordsSummary->AddColumn(
                            new
QDataGridColumn('','<?= $_CONTROL->ParentControl->render_btnToggleRecords($_CONTROL, $_ITEM) ?>
','HtmlEntities=false', 'Width=1px'));

                       // Add some QDataGrid data to show...
                        $this->dtgRecordsSummary->AddColumn(
                            new QDataGridColumn('', '<?= $_ITEM . " Records" ?>'));
                       // Add if you need another column with the other child QDataGrid to show if you need
                        $this->dtgRecordsSummary->AddColumn(
                            new QDataGridColumn('','<?= $_CONTROL->ParentControl->render_ucRecords($_CONTROL, $_ITEM) ?>','HtmlEntities=false','Width=1px'));
                       
                    } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                    }
                }

                public function dtgRecordsSummary_Bind() {
                   //Bind...
                }

                // Render other toggle...
                public function render_btnToggleRecords($parControl, $strType) {

                    $strControlId = 'btnToggleRecords' . $this->objDomain->Id . $strType;

                    if (!$objControl = $parControl->GetChildControl($strControlId)) {
                        // But in this case the parent control of the button
                        // woluld be this child QDataGrid, dont forget that...
                        $objControl = new QButton($parControl, $strControlId);
                        $objControl->Text = '+';
                        $objControl->CssClass = 'inputbutton';
                        $objControl->ActionParameter = $strType;

                        // Important! for a better coding we want to all
                        // actions referer to the child QdataGris stay
                        // in the child Qdatagrid, so the actions are now
                        // QAjaxControlAction or QServerControlAction, were the
                        // controlId parameter is $this, becaouse in $this class
                        // is defined the event for this button... kind of easy,
                        // and clean.

                        $objControl->AddAction(new QClickEvent(), new QAjaxControlAction($this,'btnToggleRecords_Click',$this->objParentObject->WaitIcon));
                    }

                    // We pass the parameter of "false" to make sure the control doesn't render
                    // itself RIGHT HERE - that it instead returns its string rendering result.
                    return $objControl->Render(false);
                }

                // Button press make other child QDataGrid Appear..
                public function btnToggleRecords_Click($strFormId, $strControlId, $strParameter) {

                    $srcControl = $this->Form->GetControl($strControlId);
                    $parControl = $srcControl->ParentControl;
                    $strType = $strParameter;

                    $objControlId = 'ucRecords' . $this->objDomain->Id . $strType;
                   
                    if ($objControl = $parControl->GetChildControl($objControlId)) {
                        if ($objControl->Visible) {
                            $objControl->Visible = false;
                            $srcControl->Text = '+';
                        } else {
                            $objControl->Visible = true;
                            $srcControl->Text = '-';
                        }
                       
                        // And refresh the Child QdataGrid this time...
                        $this->dtgRecordsSummary->Refresh();
                    }
                }

                // Create another child if you want... follow the same exactly
                // idea as applid in Master QdataGrid...
                public function render_ucRecords($parControl, $strType) {

                    $strControlId = 'ucRecords' . $this->objDomain->Id . $strType;

                    if (!$objControl = $parControl->GetChildControl($strControlId)) {

                        switch ($strType) {

                            case Records::A :
                                $objControl = new ARecordsList($this->dtgRecordsSummary, $this->objDomain, $strControlId);
                                break;

                            case Records::CNAME :
                                $objControl = new CNAMERecordsList($this->dtgRecordsSummary, $this->objDomain, $strControlId);
                                break;

                            case Records::MX :
                                $objControl = new MXRecordsList($this->dtgRecordsSummary, $this->objDomain, $strControlId);
                                break;

                            case Records::SRV :
                                $objControl = new SRVRecordsList($this->dtgRecordsSummary, $this->objDomain, $strControlId);
                               
                                break;

                            case Records::SPF :
                                $objControl = new SPFRecordsList($this->dtgRecordsSummary, $this->objDomain, $strControlId);
                                break;

                            default:
                                $objControl = new QDataGrid($parControl);
                                break;
                        }

                        $objControl->Visible = false;
                    }
                   
                    return $objControl->Render(false);
                }
        }
?>

As i say before the tpl.php file has a trick to show good we need to break the row of qdatagrid to show pretty and not break the html...

here is the code

        </td>
    </tr>
    <tr>
        <td colspan="6">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td><?php $_CONTROL->dtgRecordsSummary->Render(); ?></td>
                </tr>
            </table>
         </td>
    </tr>
    <tr>
        <td>

Well thats it, the QDataGrid, hope must be usefull for someone it was for me.

In next post gonna expand this and make it with inline editing.

Regards,

JMI

QDatagrid performance

I need some guidance on using a QDatagrid.

I've created a datagrid, which includes a check box and five text boxes. The check box has an ajax action to call a method, which does a couple of calculations (very simple +/-) and updates three of the five text boxes. This all works very well. However, the performance is incredibly bad. I've done some timings and the called method itself is negligible and remains the same, regardless of how many items are in the datagrid. However, the longer the list in the datagrid gets, the longer it takes to update the form. If there's only 15 or 20 items in the list, it's not too bad, but if that list gets much longer, the performance get really bad. Is QCubed updating the entire datagrid list?

I've thought about using pagination, but the customer won't have it. He wants to have all details listed in the datagrid. I'm wondering if it would perform much better, if I just created my own list, using QPanels, within a parent QPanel, and just manage it in arrays, similar to the way the QSortable plugin works, or is there something I can do to improve QDatagrid performance?

QCalendar control disappears in QDatagrid

I have created a datagrid, which includes a QCalendar control. It seems to work fine, unless I need to rebind the data to the grid. For example,

$this->dtgMydatagrid = new QDatagrid;

...

$this->dtgWorkOrderOps->AddColumn(new QDataGridColumn('Operation', '<?= $_ITEM->OpCode ?>', 'Width=100'));
$this->dtgWorkOrderOps->AddColumn(new QDataGridColumn('Date Complete', '<?= $_FORM->chkDateOut_Render($_ITEM) ?>','HtmlEntities=false'));

...

$this->dtgWorkOrderOps->SetDataBinder('dtgWorkOrderOps_Bind');

...

public function dtgWorkOrderOps_Bind() {
  $txtOrderByClause = QQ::Clause(QQ::OrderBy(QQN::Workorderops()->SequenceNo));
  $objWorkorderops = Workorderops::LoadArrayByWorkorderhdrsId($this->intWorkOrderId->Text,$txtOrderByClause);
  $this->WorkOrderOpsArray = array();
  foreach ($objWorkorderops as $objWorkorderop) {
    $this->WorkOrderOpsArray[] = $objWorkorderop;
  }
  $this->dtgWorkOrderOps->DataSource = $this->WorkOrderOpsArray;
}

...

public function chkDateOut_Render(Workorderops $objWorkorderop) {

  $strControlId = 'DateOut' . $objWorkorderop->Id;

  // See if the Checkbox exists already
  $DateOut = $this->GetControl($strControlId);


  if (!$DateOut) {
    $DateOut = new QCalendar($this);
    $DateOut->AddCssClass("dtgdates");
      if ($objWorkorderop->DateComplete != NULL && $objWorkorderop->DateComplete != "") {
        $DateOut->Text = $objWorkorderop->DateComplete->qFormat('MMM DD YYYY');
      }
  }
  return $DateOut->Render(false);
}

So far so good. The $DateOut displays as expected. However, if it is necessary to re-bind the data to the datagrid,

$this->dtgWorkOrderOps->DataSource = $this->WorkOrderOpsArray;

the $DateOut control simply disappears. It's heading however, does not disappear. I just get an empty column with no control.

I've been searching through the code, but haven't found anything that jumps out at me. Help.

Thanks,

LaCeja