3.2.0

Strange error on dynamicaly loaded control

Hi...

I am getting strange error on my dynamicaly loaded Combo. IE says that the control can't be activated cause it is not visible, or is disabled or does not support activation.

But here are 2 more combos patched to DatePicker on the same form and bot works like charm. Only this one doesn't. It also seems to be not included on the same layer (DIV) of the page... What the hell am I doing wrong ?

BTW: All controls calls "Not enough Premission" error after that one befor is called so whole the app have to be reloaded.

Here is Code (PHP generated JS):

<script type="text/javascript" language="javascript">
var CID = <?php echo $CID ?>;

page1 = [
                AW.all["groupParams"],
                AW.all["groupReports"],
                AW.all["buttonSubmit"],
                AW.all["buttonCancel"],
                
                AW.all["treeReport"]
                
                
            ];

            
<?php
include('../Engine/conf.inc.php');
$connection = mysql_pconnect($SQL_Server,$SQL_User,$SQL_PSWD);
mysql_select_db($SQL_DB);
mysql_query("SET CHARACTER SET utf8", $connection);
mysql_query("SET NAMES 'utf8'", $connection);



function combo_setup($dataset){
    $result_text = '[';
    $result_value = '[';
    $num_rows = mysql_num_rows($dataset);
    $i = 1;
    while ($row = @mysql_fetch_array($dataset)) 
    {
        $result_text .= '"'.$row['param_value']." - ".$row['param_text'].'"';
        $result_value .= '"'.$row['param_value'].'"';

        if($i < $num_rows)
        {
            $result_text .= ',';
            $result_value .= ',';
            $i++;
        }
    }
    echo 'comboText = '.$result_text.'];'."\n\t";
    echo 'comboValue = '.$result_value.'];'."\n\t";
    echo 'comboItems = '.$num_rows.';'."\n\t";
    }





$query = "	Select
                ReportLink
            From
                WAIS_Reports
            WHERE ID = '".$reportID."'
";



$dataset = @mysql_query($query, $connection);

while ($record = @mysql_fetch_array($dataset))
{
        $ReportLink = $record['ReportLink']."?CID='+CID";
}

$query = "	Select
                *
            From
                WAIS_ReportParams
            WHERE Report_ID = '".$reportID."'
";



$dataset = @mysql_query($query, $connection);

$rows = array();
$paramno = 1;
while ($record = @mysql_fetch_array($dataset))
{
    
    echo "
            var label".$record['Param_Name']." = new AW.UI.Label;
            label".$record['Param_Name'].".setId('label".$record['Param_Name']."');
            label".$record['Param_Name'].".setControlText('".$record['Param_Label']."');
            label".$record['Param_Name'].".setPosition(31, ".((($paramno-1)*25)+81).");
            label".$record['Param_Name'].".setSize(100, 16);
        
        
        
        ";
    echo "page1[".(5+($paramno))."] = label".$record['Param_Name'].";\n\n";
    
    if($record['Param_Type'] == 'date')
    {
        


        echo 	"DateObject".$paramno." = new Date();
                ".$record['Param_Name']."OnSelect = function(".$record['Param_Name']."Datepicker, date) 
                {
                    combo".$record['Param_Name'].".setControlText(date);
                    if (".$record['Param_Name']."Datepicker.dateClicked)
                    {
                        ".$record['Param_Name']."Datepicker.callCloseHandler(); // this calls 'onClose' (see above)
                    }
                };
            
            
                ".$record['Param_Name']."OnClose = function(".$record['Param_Name']."Datepicker) {
                    ".$record['Param_Name']."Datepicker.hide();
                    // or calendar.destroy();
                };
            
                var ".$record['Param_Name']."Datepicker = new Calendar(1,null, ".$record['Param_Name']."OnSelect, ".$record['Param_Name']."OnClose);
                ".$record['Param_Name']."Datepicker.weekNumbers = false;
                ".$record['Param_Name']."Datepicker.showsTime = false;
                ".$record['Param_Name']."Datepicker.setDateFormat('%d.%m.%Y');
                
                ".$record['Param_Name']."Datepicker.create();
                
                
                
                var combo".$record['Param_Name']." = new AW.UI.Combo;
                combo".$record['Param_Name'].".setId('combo".$record['Param_Name']."');
                combo".$record['Param_Name'].".setControlText(DateObject".$paramno.".print('%d.%m.%Y'));
                combo".$record['Param_Name'].".setPosition(31, ".((($paramno-1)*25)+101).");
                combo".$record['Param_Name'].".setSize(180, 20);
                combo".$record['Param_Name'].".setItemText('');
                combo".$record['Param_Name'].".setItemValue('');
                combo".$record['Param_Name'].".setItemCount(0);
                combo".$record['Param_Name'].".getPopupTemplate().setStyle('width',combo".$record['Param_Name'].".getStyle('width'));
                combo".$record['Param_Name'].".getPopupTemplate().setStyle('height',17*(combo".$record['Param_Name'].".getItemCount()<10?combo".$record['Param_Name'].".getItemCount():10));
                combo".$record['Param_Name'].".getContent('box/text').setAttribute('readonly', true);
                combo".$record['Param_Name'].".onControlEditStarted = function(){
                    this.getContent('box/text').element().contentEditable = false;
                }
                combo".$record['Param_Name'].".onControlClicked = function() {
                    this.showPopup();
                }
                combo".$record['Param_Name'].".showPopup = function(){
                    ".$record['Param_Name']."Datepicker.showAt(31, ".((($paramno-1)*25)+171).");	
                }
                
                ";
                $ReportLink .= "+'&".$record['Param_Name']."='+AW.all['combo".$record['Param_Name']."'].getControlText().substr(0,10)";
                echo "page1[".(5+($paramno+1))."] = combo".$record['Param_Name'].";\n\n";
        
                
    }
    if($record['Param_Type'] == 'combo')
    {
    
    
                $combo_dataset = mysql_query($record['Param_Value']);							
                combo_setup($combo_dataset);
                
                echo "var combo".$record['Param_Name']." = new AW.UI.Combo;
                combo".$record['Param_Name'].".setId('combo".$record['Param_Name']."');
                combo".$record['Param_Name'].".setControlText('');
                combo".$record['Param_Name'].".setPosition(31, ".((($paramno-1)*25)+101).");
                combo".$record['Param_Name'].".setSize(180, 20);
                combo".$record['Param_Name'].".setItemText(comboText);
                combo".$record['Param_Name'].".setItemValue(comboValue);
                combo".$record['Param_Name'].".setItemCount(comboItems);
                combo".$record['Param_Name'].".setSelected('1')
                combo".$record['Param_Name'].".getPopupTemplate().setStyle('width',combo".$record['Param_Name'].".getStyle('width'));
                combo".$record['Param_Name'].".getPopupTemplate().setStyle('height',17*(combo".$record['Param_Name'].".getItemCount()<10?combo".$record['Param_Name'].".getItemCount():10));
                combo".$record['Param_Name'].".getContent('box/text').setAttribute('readonly', true);
                combo".$record['Param_Name'].".onControlEditStarted = function(){
                    this.getContent('box/text').element().contentEditable = false;
                }
                combo".$record['Param_Name'].".onControlClicked = function() {
                    this.showPopup();
                }
                
                ";
                $ReportLink .= "+'&".$record['Param_Name']."='+AW.all['combo".$record['Param_Name']."'].getControlText().substr(0,10)";
                echo "page1[".(5+($paramno+1))."] = combo".$record['Param_Name'].";\n\n";
    }
    
    else
    {
        
    }
    
    
    $paramno = $paramno+2;
}


?>
    
    AW.all["buttonSubmit"].onClick = function(){
        
        //alert(treeReport.getSelectedItems() +"/" + treeReport.getAttribute("NodesCount"));
        
        if (AW.all["treeReport"].getSelectedItems() <= AW.all["treeReport"].getAttribute("NodesCount"))
        {
            alert("Zvolte prosím sestavu pro zobrazení");
        }
        else
        {
            reportWindow = window.open(<? echo "'".$ReportLink?>,'','resizable');
            reportWindow.focus();
        }
    }
    
    AW.all["reportContainer"].element().innerHTML = page1.join("");
    document.WAIS_loading.src = "images/design/blank.gif";
    
    //alert('POZOR:\n\nSystém sestav je do&#269;asn&#283; nedostupný\n\n(vrácený kód:\t'+AW.all["treeReport"].getItemValue(AW.all["treeReport"].getSelectedItems()-1)+')\n\n/PNC/Reports/DR_visits_report.php?CID='+CID+'&date_from='+AW.all['combodate_from'].getControlText().substr(0,10)+'&date_to='+AW.all['combodate_to'].getControlText().substr(0,10));

</script>


Description how it woks:

The form has a Tree control, that is used to select the REPORT to be displayed. Any Report can have its parameters, so when Tree item is changed, this script is called to get params for that report and add/remove them from the form.

All works, but classic combo doesn't

WHY?
January 29,
Well ROFL to my self... I found the bug... Perhaps it shoud be the behaviour of Browser and JS, but Mea Culpa, Mea Maxima Culpa... ;-)

As you see in the PHP script above, the Combo is created as Combo_paramName. The point was, that the parameter name was set to OTZ, but there already was comboOTZ in my application but hidden in DIV (style.visibility= "hidden") with application data under the DIV shown to let me chose the report...

So please Beware of the same STUPID errors, that took me whole day to solve ;-)

January 29,

This topic is archived.

See also:


Back to support forum