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

ajax

Ajax Bug on Long Running Action?

Hello,

I am experiencing a issue when I create a button with a QAjax Action attached to it running a long action (like a button with a click event). If you try to hit a URL on the page before the action is complete, it gives an error message (with an empty error window). It in fact sounds like what Mike Ho describes on this forum about a bug in QCodo (now fixed apparently): http://www.qcodo.com/forums/forum.php/3/2281

I'm wondering if this was fixed in QCubed as well, as I'm still getting this problem for some reason (using QCubed 2.0).

Create a control with expandable subcontrol

Hello all,

I am trying to develop a small app for a shop which lists down products. It is needed to list down each product in its own box (visible). This box is to show the basic specifications of a product but must contain another box with detailed specs, availability, price, offers, etc.

If would look like this when not expanded:

----------------------------------
| SOME BASIC INFO |
| |
| [Details button] |
----------------------------------

and when expanded:

----------------------------------
| SOME BASIC INFO |
| |
| [Hide Details button] |
+---------------------------------+
| |
| SOME DETAILED INFO (QTabs) |
| |
| |
----------------------------------

So I created a custom control for the box with a div to show the upper part and the lower part was a QTabs.

Now, it is needed that when the [Details] button is clicked, an Ajax call is made to server, and the QTabs be generated and presented on client screen. And here is the list of problems I am facing:

1. Ajax calls are not working (blank window popup after a "AJAX parse error" dialog box popup).
2. I tried to use ToggleDisplay but it does not seem to work when the QTabs is initially hidden!

3. I tried to create a subcontrol but no use. The problem persists.

Kindly suggest what can be done here? I do not think a QPanel can be used there either because that, too is failing!

Regards.

Probleme with ajax pagination

Hello.
I'm having a problem with datagrid paging.
My page1 (qForm) is loaded from ajax (jQuery tabs) in another page0 (qForm). Page1 has a datagrid with paging (ajax on). When making the pagination (click on the next figure or another page) my page out of context page0-> page1 and appears by itself (the address of my browser also shows www.monsite/page1. php). Do you have a suggestion or an idea of where it may come ?

Here is the code php datagrid and bind :

<?php
   
protected function gridComments_Create() {
       
$this->grid_suggestions = new QDataGrid($this);
       
$this->grid_suggestions->CellPadding = 5;
       
$this->grid_suggestions->CellSpacing = 0;
       
$this->grid_suggestions->AddCssClass("display");
       
$this->grid_suggestions->AddCssClass("datagrid");
       
$this->grid_suggestions->UseAjax = true;

       
$objPaginator = new QPaginator($this->grid_suggestions, 'paginatorFELAnalysis');
       
$this->grid_suggestions->Paginator = $objPaginator;
       
$this->grid_suggestions->ItemsPerPage = 5;

       
// Define Columns
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Origin Comments', "<?= $_ITEM->OriginComments ?&gt;", "Width=80",
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->OriginComments), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->OriginComments, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Reception Date', "<?= $_ITEM->ReceptionDate ?&gt;", 'Width=80',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->ReceptionDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->ReceptionDate, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Language', "<?= $_ITEM->AelLanguageIdaelLanguageObject->Name3rdEn ?&gt;", 'Width=auto',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->AelLanguageIdaelLanguage), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->AelLanguageIdaelLanguage, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('First Name', "<?= $_ITEM->FirstName ?&gt;", 'Width=128',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->FirstName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->FirstName, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Last Name', "<?= $_ITEM->LastName ?&gt;", 'Width=128',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->LastName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->LastName, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Email', "<?= $_ITEM->Email ?&gt;", 'Width=auto',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->Email), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->Email, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Official title', "<?= $_ITEM->OfficialTitle ?&gt;", 'Width=auto',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->OfficialTitle), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->OfficialTitle, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Institution', "<?= $_ITEM->Institution ?&gt;", 'Width=auto',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->Institution), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->Institution, false))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Other autorities', "<?= $_ITEM->OtherAutorities ?&gt;", 'Width=250',
                        array(
'OrderByClause' => QQ::OrderBy(QQN::AelComments()->OtherAutorities), 'ReverseOrderByClause' => QQ::OrderBy(QQN::AelComments()->OtherAutorities, true))));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Workflow', "<?= $_FORM->lstSelected_Render($_ITEM) ?&gt;<br />", 'HtmlEntities=false'));
       
$this->grid_suggestions->AddColumn(new QDataGridColumn('Analysis', "<?= $_FORM->EditColumn_Render($_ITEM) ?&gt;", 'HtmlEntities=false'));

       
/* Styles */
       
$objStyle = $this->grid_suggestions->RowStyle;
       
$objStyle->FontSize = 9;
       
$objStyle->BackColor = '#dfdfdf';

       
$objStyle = $this->grid_suggestions->AlternateRowStyle;
       
$objStyle->BackColor = '#fcf7ff';

       
$objStyle = $this->grid_suggestions->HeaderRowStyle;
       
$objStyle->FontSize = 9;
       
$objStyle->ForeColor = '#e5e5eb';
       
$objStyle->BackColor = '#4c4f72';

       
$objStyle = $this->grid_suggestions->HeaderLinkStyle;
       
$objStyle->ForeColor = '#e5e5eb';

       
// Let's make sorting Ajax-ified
       
$this->grid_suggestions->SetDataBinder('comments_Bind', $this);
    }

   
/* Sorting default */

   
protected function comments_Bind() {
       
$conditions[] = QQ::In(QQN::AelComments()->AelCommentsStatusIdaelCommentsStatusObject->Status, array(_ACT_STATUS_PHASE4));
       
$clauses[] = QQ::Expand(QQN::AelComments()->AelCommentsStatusIdaelCommentsStatusObject);
       
$clauses[] = QQ::Expand(QQN::AelComments()->AelPointsIdaelPointsObject);
       
$clauses[] = QQ::Expand(QQN::AelComments()->AelLanguageIdaelLanguageObject);
       
$clauses[] = QQ::OrderBy(QQN::AelComments()->AelCommentsStatusIdaelCommentsStatusObject->Status, QQN::AelComments()->ReceptionDate);
       
$this->grid_suggestions->TotalItemCount = AelComments::QueryCount(QQ::AndCondition($conditions));
       
$clauses[] = $this->grid_suggestions->LimitClause;
       
$this->grid_suggestions->DataSource = AelComments::QueryArray(QQ::AndCondition($conditions), $clauses);
    }
?>

DataGrid sorting: Ajax is not working: Err: This control has already been rendered c6

I have a datagrid and it's not working whenever I enable Ajax.

The error points to here:
This control has already been rendered: c6
/includes/qcubed/_core/base_controls/QControlBase.class.php Line: 1091
Line 1091: return $this->$strRenderMethod($blnDisplayOutput);

When I set UseAjax to false, it works. Any idea why this is happening?
My codes:

                        // Active Listing DataGrid
                        $this->dtgActiveListings = new ItemDataGrid($this);
                        $this->dtgActiveListings->Paginator = new QPaginator($this);
                        $this->dtgActiveListings->ItemsPerPage = 20;
                        $this->dtgActiveListings->UseAjax = true;
                        $this->dtgActiveListings->ShowFilter = false;

                        $this->dtgActiveListings->SetDataBinder('dtgActiveListings_Bind');
                        $this->dtgActiveListings->MetaAddColumn('Title');

...



                protected function dtgActiveListings_Bind() {
                        $this->dtgActiveListings->Paginator->Visible = true;
                        $this->dtgActiveListings->TotalItemCount = Item::QueryCount(
                                QQ::AndCondition(
                                        QQ::Equal(QQN::Item()->IsActive, 1),
                                        QQ::Equal(QQN::Item()->SellerId, QApplication::$User->Id)));
                        $this->dtgActiveListings->DataSource = Item::QueryArray(
                                QQ::AndCondition(
                                        QQ::Equal(QQN::Item()->IsActive, 1),
                                        QQ::Equal(QQN::Item()->SellerId, QApplication::$User->Id)),
                                QQ::Clause($this->dtgActiveListings->LimitClause, $this->dtgActiveListings->OrderByClause));
                }

Error in qcubed.js ?

Hi everyone,
while I was trying to use an EditPanel draft, I noticed that the save button didn't work. It was because I had a javascript error "children is not a function" at line 191 of qcubed.js
I tried changing that line from

this.children(':selected').each (function (i) {

to

$j(this).children(':selected').each (function (i) {

And now it works.
What do you think?

Thanks
Luca

Ajax Bug?

Hi,

I've been starting my development from the generated panel files in the drafts->panel folder, the "Dashboard".

I have two problems:

1)
I've been monitoring that the ajax responses do not only send back the controls which have changed, but also controls that didn't change at all (I made a diff on some ajax responses).

The return structure is follows the known pattern:
response>
controls>
control id="c169">
...

You can observe this behaviour for example when browsing the Ajax Dashboard of the "Project" example. When clicking on the edit or new button, not only the QPanel pnlEdit, but also the whole table pnlList ist send in the ajax response. the pnlList didn't change at all.

What needs to be changed configured that the framework only sends changed controls?

2)
I have a QControlProxy performing a QServerControlAction with an onClickEvent.

The triggered pxyControl_Click($strFormId, $strControlId, $strParameter) function then returns a vcard file following way:

<?php
public function pxyControl_Click($strFormId, $strControlId, $strParameter){
...
       
$output = $v->getVCard();
       
$filename = $v->getFileName();

       
Header("Content-Disposition: attachment; filename=$filename");
       
Header("Content-Length: ".strlen($output));
       
Header("Connection: close");
       
Header("Content-Type: text/x-vCard; name=$filename");

        echo
$output;
}
?>

As result, I get the VCard file, but it doesn't only contain the $output vcard string, but also

...
END:VCARD
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
head>
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    title>Business Warehouse</title>
           
    link rel="stylesheet" type="text/css" href="/dev/assets/_core/css/styles.css"/>
...

html code of my main page. Why does QCubed returns that html part?

Lot of questions and I've been trying to investigate for hours without success. Therefore I hope for some help here :-)

Thanks,
Nick

New Plugin: QVisualEvent Ajax Debugger Tool

Hello folks

This is my weekly contribution to Qcubed a new Control to improve our debugging in our applications.

QVisualEvent is a wrapper for http://www.sprymedia.co.uk/article/Visual+Event, this is an awesome tool for JS event finder

Even although Javascript (in the browser at least) is an event driven programming paradigm, it can often be really quite difficult to identify which elements will trigger an action. QVisualEvent is designed to address exactly this problem.

Problem with Ajax error messages

Hi!

Had same problem with Qcodo, now I tried the Qcuped but I`m still not abel to get correct error message...
Still sometimes I have seen readable Ajax error messages (but not for a long time).

One example:

QForm bug

Hi,

I don't know if i call it a bug or whatever..

1) In the form drafts generated by qcodo... if you are in text field and press enter.. the page get refreshed.. (probably form get submitted) but nothing happens.

2) If you do same in ajax dashbord (instead of pressing save button, hit the enter key while curser in any text field) .. it will through the direct xml on page... You probably need to put the same event on < form onSubmit ... that is fired onClick of save button.

Events not working

Hello, I'm new here. I just started using qcubed and I really like it, but I can't seem to get it working on my shared server. It works fine on xampp, but the events are not firing on the server:
See here: http://phareo.ossoft.org/tester/tester.php

tester.php:
<?php
require('config.php');
require(__LIBROOT__ . 'includes/prepend.inc.php');
class test extends QForm
{
protected $button1;
protected function Form_Create(){
$this->button1 = new QButton($this);
$this->button1->Text = "Click";
$this->button1->AddAction(new QClickEvent(), new QAjaxAction('button1_click'));