QDatagrid inside QPanel not working

thread: 7 messages  |  last: about 7 years ago  |  started: monday, september 26, 2011, 3:17 pm pdt


#1  |  sumitkumarg (india) Bahamas
Monday, September 26, 2011, 3:17 PM PDT

QDatagrid inside QPanel not working. I am attaching some code where pagination and sorting not working. It is rederect to parent page even i am using $this->dtgUserpackage->UseAjax = true;


Please see the code below.If any thing missing so let me know.


<?php
require “dlgpackage.class.php”;
class Package extends QPanel {
   
   protected $strTemplate = 'panel/package.tpl.php';
   public $objUser,$strControlId;
   public $dtgUserpackage,$dlgPackage;
   public $btnNew,$btnDeleteSelected,$btnExport;
   public $lblUserUserpackage;
   public $arrDeleteByCheckBox;
   public $intEditUserpackageId=null;
   public $objDefaultWaitIcon,$str;
       
   public function __construct($objParentObject,$objUser,$strControlId = null) {
           try {
               parent::__construct($objParentObject, $strControlId);
           } catch (QCallerException $objExc) {
               //$objExc->IncrementOffset();
               //throw $objExc;
           }                

           $this->objUser=$objUser;
           $this->strControlId=$strControlId;
           
           $this->dlgPackage = new QDlgPackage('btndlgPackage_Close', $this, 'PackageDialogbox');
           $this->dlgPackage->Title = “Plan”;
           $this->dlgPackage->Visible = false;
           
           $this->btnNew=new QButton($this);
           $this->btnNew->Text=QApplication::Translate('Purchase New Plan');
           $this->btnNew->ActionParameter = “-1”;
           $this->btnNew->AddAction(new QClickEvent(), new QAjaxControlAction($this,'btnEdit_Click'));
           
           
           $this->dtgUserpackage=new QDataGrid($this);
           
           $objPaginator = new QPaginator($this->dtgUserpackage);

           $this->dtgUserpackage->Paginator = $objPaginator;
           $this->dtgUserpackage->Width = '700';
           $this->dtgUserpackage->ItemsPerPage = 1;
           $this->dtgUserpackage->UseAjax = true;
           $this->dtgUserpackage->SetDataBinder('dtgUserpackage_Bind', $this);
           
           $this->dtgUserpackage->SortColumnIndex=0;
           $objStyle = $this->dtgUserpackage->AlternateRowStyle;
           $objStyle->BackColor = '#efefef';    
           
           
           /*$this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Action',
                               ('<?= $_CONTROL->ParentControl->WebLink($_ITEM) ?>'),
                               'Width=50',
                               'HtmlEntities=false'
                               ));*/
           /*$this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Action',
                               ' <?= $_CONTROL->ParentControl->EditColumn_Render($_ITEM) ?>',
                               'Width=200',
                               'HtmlEntities=false'
                               ));*/
           $this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Plan Name',
                               ' <?= $_CONTROL->ParentControl->PackageColumn_Render($_ITEM) ?>',
                               'Width=200',
                               'HtmlEntities=false',
                               array(
                                       'OrderByClause'=>QQ::OrderBy(QQN::OcsUserpackage()->Package->Name),
                                       'ReverseOrderByClause' => QQ::OrderBy(QQN::OcsUserpackage()->Package->Name,false)
                               )));
                               
           $this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Price Left',
                               ' <?= $_CONTROL->ParentControl->Priceleft_Render($_ITEM) ?>',
                               'Width=200',
                               'HtmlEntities=false',
                               array(
                                       'OrderByClause'=>QQ::OrderBy(QQN::OcsUserpackage()->Priceleft),
                                       'ReverseOrderByClause' => QQ::OrderBy(QQN::OcsUserpackage()->Priceleft,false)
                               )));

           $this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Status',
                               ' <?= $_CONTROL->ParentControl->StatusColumn_Render($_ITEM) ?>',
                               'Width=200',
                               'HtmlEntities=false',
                               array(
                                       'OrderByClause'=>QQ::OrderBy(QQN::OcsUserpackage()->Isactive),
                                       'ReverseOrderByClause' => QQ::OrderBy(QQN::OcsUserpackage()->Isactive,false)
                               )));                    
           
                               
           $this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Purchase Date',
                               ' <?= $_CONTROL->ParentControl->DatedColumn_Render($_ITEM) ?>',
                               'Width=350',
                               'HtmlEntities=false',
                               array(
                                       'OrderByClause'=>QQ::OrderBy(QQN::OcsUserpackage()->Dated),
                                       'ReverseOrderByClause' => QQ::OrderBy(QQN::OcsUserpackage()->Dated,false)
                               )));
                               
           $this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Exp Date',
                               ' <?= $_CONTROL->ParentControl->ExpdatedColumn_Render($_ITEM) ?>',
                               'Width=350',
                               'HtmlEntities=false',
                               array(
                                       'OrderByClause'=>QQ::OrderBy(QQN::OcsUserpackage()->Expdated),
                                       'ReverseOrderByClause' => QQ::OrderBy(QQN::OcsUserpackage()->Expdated,false)
                               )));
           
           /*$this->dtgUserpackage->AddColumn(new QDataGridColumn(
                               'Select',
                               '<?= $_CONTROL->ParentControl->chkSelected_Render($_ITEM) ?>',
                               'Width=50',
                               'HtmlEntities=false'
                               ));*/    
           $this->btnDeleteSelected=new QButton($this->dtgUserpackage);
           $this->btnDeleteSelected->Text='Delete Selected';$this->btnDeleteSelected->CssClass='floatright button';
           $this->btnDeleteSelected->AddAction(new QClickEvent(), new QAjaxControlAction($this,'btnDeleteSelected_Click'));
           $this->objDefaultWaitIcon = new QWaitIcon($this);
       
       
       
       
       

       
   }
public function dtgUserpackage_Bind(){
           $this->dtgUserpackage->TotalItemCount = OcsUserpackage::QueryCount(
                                                                                   QQ::Equal(QQN::OcsUserpackage()->UserId,$_SESSION['UserId'])
                                                                               );

           $objUserpackageArray=$this->dtgUserpackage->DataSource=OcsUserpackage::QueryArray(
                                                                                   QQ::Equal(QQN::OcsUserpackage()->UserId,$_SESSION['UserId'])
                                                                               ,QQ::Clause($this->dtgUserpackage->OrderByClause,$this->dtgUserpackage->LimitClause));
                                           
       }
       public function btnDeleteSelected_Click($strFormId, $strControlId, $strParameter) {
           if($this->intEditUserpackageId!=-1){
               if(count($this->arrDeleteByCheckBox)){
                   foreach($this->arrDeleteByCheckBox as $key=>$value){
                       if($value!=''){
                           if($objUserpackage = OcsUserpackage::Load($value))
                               $objUserpackage->Delete();
                       }
                       
                   }
               }
           }
           $this->intEditUserpackageId = null;
       }
       public function btnNew_Click($strFormId, $strControlId, $strParameter) {

           QApplication::Redirect(_VIRTUAL_DIRECTORY_OCS_.
                               “/admin/user/package/edit.php?UserpackageId=-1&UserId=“.QApplication::QueryString('UserId'));
       }        

       public function chkSelected_Click($strFormId, $strControlId, $strParameter){
           $intUserpackageId = $strParameter;
           if($intUserpackageId !=-1 && $intUserpackageId!='' && $intUserpackageId!=null){    
               $objUserpackage = OcsUserpackage::Load($intUserpackageId);
               if ($this->GetControl($strControlId)->Checked){
                   $this->arrDeleteByCheckBox[]=$objUserpackage->UserpackageId;
               }
               else{    
                   $delthis=array_search($objUserpackage->UserpackageId,$this->arrDeleteByCheckBox);
                   array_splice($this->arrDeleteByCheckBox, $delthis, 1);
               }
           }
       }
       public function WebLink(OcsUserpackage $objUserpackage){
           $strToReturn = “<a style='text-decoration:none;color:#323232;border:1px solid #bcbcbc;
                           padding:2px;background-color:#ccdddd'
                           href=\”package/edit.php?UserId=“.QApplication::QueryString('UserId').”&UserpackageId=“.$objUserpackage->UserpackageId.”\”>Edit</a>”;
           return $strToReturn;
       }
       public function PackageColumn_Render(OcsUserpackage $objUserpackage){
           return QApplication::HtmlEntities($objUserpackage->Package->Name);
       }
       public function StatusColumn_Render(OcsUserpackage $objUserpackage){
           if($objUserpackage->Isactive=='1'){
               return QApplication::HtmlEntities('Active');
           }else{
               return QApplication::HtmlEntities('Inactive');
           }
       }            
       public function ExpdatedColumn_Render(OcsUserpackage $objUserpackage){
           if($objUserpackage->Expdated)
               return $objUserpackage->Expdated;
           else
               return '--';
       }
       public function DatedColumn_Render(OcsUserpackage $objUserpackage){
           if($objUserpackage->Dated)
               return $objUserpackage->Dated;
           else
               return '--';
       }
       public function Priceleft_Render(OcsUserpackage $objUserpackage){
           $str=OcsCustomFunc::convertstrcenttodoller($objUserpackage->Priceleft);
           return QApplication::HtmlEntities($str);
       }
       public function chkSelected_Render(OcsUserpackage $objUserpackage){
           $strControlId = 'chkSelected' . $objUserpackage->UserpackageId;
           $chkSelected = $this->GetControl($strControlId);
           
           if(!$chkSelected){
               $chkSelected=new QCheckBox($this->dtgUserpackage,$strControlId);
               $chkSelected->ActionParameter=$objUserpackage->UserpackageId;
               $chkSelected->AddAction(new QClickEvent(),new QAjaxAction('chkSelected_Click'));
           }
           return $chkSelected->Render(false);
       }
       public function btnEdit_Click($strFormId, $strControlId, $strParameter) {
           //QApplication::DisplayAlert(“Yes-->”.$strParameter);
           
           $this->dlgPackage->Value = $strParameter;
           
           $this->dlgPackage->ShowDialogBox();
       }
       public function EditColumn_Render(OcsUserpackage $objUserpackage){
           $strControlId=$objUserpackage->UserpackageId;
           
           $btnEdit = new QButton($this->dtgUserpackage);
           $btnEdit->Text = 'View';
           $btnEdit->ActionParameter = $objUserpackage->UserpackageId;
           $btnEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this,'btnEdit_Click'));
           
           return $btnEdit->Render(false);
           
       }
       public function btndlgPackage_Close(){
           
           //$this->txtValue->Text = $this->dlgPackage->Value;
           //QApplication::Redirect(_VIRTUAL_DIRECTORY_OCS_.”/user/ccinfo.php?PackageId='”.$this->dlgPackage->Value.”'”);
           
       }
}
?>

#2  |  Mike Ho (San Diego, CA) United States of America Qcodo Administrator
Monday, September 26, 2011, 9:12 PM PDT

Wow... way too much code.

If you're going to post code, please keep it to the absolute bare minimum of code that shows the issue or highlights the question that you have.

#3  |  sumitkumarg (india) Bahamas
Tuesday, September 27, 2011, 3:35 PM PDT

Hi
I am accessing QDataGrid in QPanel.But now sorting and pagination is not working it is refreshing a page and called a parent page  even i am using
$this->dtgEasydial->UseAjax = true;

Once i am clicking on Delete button of datagrid then its working fine.


Please see the code for datagrid:

$this->dtgEasydial=new QDataGrid($this);
         
          $objPaginator = new QPaginator($this->dtgEasydial);

          $this->dtgEasydial->Paginator = $objPaginator;
          $this->dtgEasydial->Width = '700';
          $this->dtgEasydial->ItemsPerPage = 2;
          $this->dtgEasydial->UseAjax = true;
          $this->dtgEasydial->SetDataBinder('dtgEasydial_Bind', $this);
         
          $this->dtgEasydial->SortColumnIndex=0;



$this->btnDeleteSelected=new QButton($this->dtgEasydial);
$this->btnDeleteSelected->Text='Delete Selected';
$this->btnDeleteSelected->AddAction(new QClickEvent(), new AjaxControlAction($this,'btnDeleteSelected_Click'));
$this->objDefaultWaitIcon = new QWaitIcon($this);



Now delete button is calling  below function




public function btnDeleteSelected_Click($strFormId, $strControlId, $strParameter) {
          if($this->intEditEasydialId!=-1){
              if(count($this->arrDeleteByCheckBox)){
                  foreach($this->arrDeleteByCheckBox as $key=>$value){
                      if($value!=''){
                          if($objEasydial = OcsEasydial::Load($value))
                              $objEasydial->Delete();
                      }
                  }
              }
              else {
                  QApplication::DisplayAlert(“Please select atleast one check box!”);
              }
          }
          $this->intEditEasydialId = null;
          $this->dtgEasydial_Bind();
      }



Please suggest what would be the next step to do?

#4  |  sumitkumarg (india) Bahamas
Tuesday, September 27, 2011, 3:37 PM PDT

public function dtgUserpackage_Bind(){
          $this->dtgUserpackage->TotalItemCount = OcsUserpackage::QueryCount(
                                                                                  QQ::Equal(QQN::OcsUserpackage()->UserId,$_SESSION['UserId'])
                                                                              );

          $objUserpackageArray=$this->dtgUserpackage->DataSource=OcsUserpackage::QueryArray(
                                                                                  QQ::Equal(QQN::OcsUserpackage()->UserId,$_SESSION['UserId'])
                                                                              ,QQ::Clause($this->dtgUserpackage->OrderByClause,$this->dtgUserpackage->LimitClause));
                                         
      }

#5  |  sumitkumarg (india) Bahamas
Tuesday, September 27, 2011, 3:40 PM PDT

sdfs

#6  |  sumitkumarg (india) Bahamas
Tuesday, September 27, 2011, 3:43 PM PDT

aa

#7  |  Mike Ho (San Diego, CA) United States of America Qcodo Administrator
Tuesday, September 27, 2011, 9:10 PM PDT

Sumit,

It's still too hard to try and ferret thru all that code.

If you want folks to help out to try and debug your issues, you've gotta at least do a little bit of work on your end to try and make it as clear and as easy to go through your code.

If you're having an issue with something within a custom QPanel, then you'll need to provide more or less 4 code listings.

It should be your main php file (e.g. the QForm definition itself), the main php file's HTML TPL file.  And then a class.php file for your custom QPanel, and the template TPL file for that custom QPanel.

Note: Each of these files should have absolutely no more than 5-10 lines of code in it.  If there is more, then you're clearly including things that don't need to be in there to exhibit the bug / issue you are seeing.

The best way to do this is to create these four files from scratch... confirm that it still shows your bug/issue, and then post the listing for these four files.

Finally -- please note that you are posting on the Qcodo forums... however, from your other post, it looks like you may be using Qcubed.  Qcubed branched from Qcodo several years ago, and the current version of Qcubed can operate differently than Qcodo.  It might be a good idea to post there to get help for Qcubed-related issues.  In short, if you end up posting code and folks here can't replicate your issue since we're on Qcodo v4.22 and you're using Qcubed vX.Y, then there's really little that we can do to help.

HTH.  Definitely feel free to post once you've got some more concise code listings that we can more easily go through.



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