QDataGrid
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
Error rendering QCalendar in QDatagrid
I've created a QDatagrid, with inline editing. One of the controls in the datagrid is a QCalendar. If that control is populated with a date, I get the following error:
Fatal error: Call to a member function Render() on a non-object in C:\xampp\htdocs\htw2\wla\testresults_edit.php on line 536I have several controls rendered for inline edit and they all work fine, if I simply remove the QCalendar. It also works if the QCalendar is not populated with a date. Here's the code, where the column is added:
$this->dtgWorkOrderOps->AddColumn(new QDataGridColumn('Date Complete', '<?= $_FORM->chkDateOut_Render($_ITEM) ?>','HtmlEntities=false'));... and the public function, where the control is created and rendered:
public function chkDateOut_Render(Workorderops $objWorkorderop) {
$strControlId = 'DateOut' . $objWorkorderop->Id;
// See if it exists already
$DateOut = $this->GetControl($strControlId);
if (!$DateOut) {
$DateOut = new QCalendar($this);
$DateOut->AddCssClass("dateclass");
if ($objWorkorderop->DateComplete != NULL) {
$DateOut = $objWorkorderop->DateComplete->qFormat('MMM DD YYYY');
}
}
return $DateOut->Render(false);
}I'm using 2.0 of QCubed. Is this a bug or is there something wrong with my code. If I create a QCalendar control on the form (not in the datagrid), the date renders with no problems. The problem only occurs, when I put it in a datagrid.
QDataGrid and DataBinder
Hello All,
Please kindly assist me look into this:
I have a QDataGrid I use for Reporting. I also have report spans (Today's Report, This week's report, This Month's Report, This Year, and Custom). The idea is that i change the data in the Datagrid to match the selected span for the report.
However, I noticed that whenever i switch to another report span, the OrderByClause and LimitClause of the previous data binded are carried over to this one so that I get WIERD paginations link "210-230 of 87".
I used the setclauses statement before I execute query array as follows:
protected function setDatagridClauses(){
// Setup the $objClauses Array
$objClauses = array();
// If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
// the OrderByClause to the $objClauses array
if ($objClause = $this->dtgCertReport->OrderByClause)
array_push($objClauses, $objClause);
// Add the LimitClause information, as well
if ($objClause = $this->dtgCertReport->LimitClause)
array_push($objClauses, $objClause);
return $objClauses;
}My QUESTION:
How do I clear the previous OrderByClauses and LimitClauses before I execute the QueryArray statement so I don't carry over unwanted behaviours as described above.
Thank you so much.
QDataGrid inside QDataRepeater
I need to have a QDataRepeater which in turn renders a QDataGrid object which is based on a related piece of data.
ex: I have a list of customers displayed by the QDataRepeater. For each customer I want to list all of their transactions in the QDataGrid.
I have the datarepeater working just fine. The datagrid needs to display an array of objects which can be obtained through a call to the Customer object.
