CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Editable grid - radio button sql based on field value [Solved]

Print topic Send  topic

Author Message
beefcake

Posts: 9
Posted: 10/21/2016, 6:33 PM Quote message

Hi All,

In an editable grid I am trying to dynamically alter a radio buttons SQL based on a field value (question_id) within the editable grid row.

I have tried in almost all events without success? any help appreciated.

$myform->a_radio->DataSource->SQL="SELECT answer_id, answer_text FROM tbl_Answers Where question_id=".$myform->question_id->GetValue();

**In ASP classic you could do this in before show row event of the editable grid but doesn't work in php.
View profile  Send private message
DataDoIT
Posted: 10/22/2016, 7:25 AM Quote message

There are three properties for dynamically modifying the SQL of a
control: SQL, Where, and Order By.

http://docs.codecharge.com/studio50/html/ProgrammingTec.../ModifySQL.html

All three are then concatenated to build the full SQL string.

It looks as if you're pulling the value from question_id, but note that
it is pulling the -displayed- value of that control. Thus be certain
that the question_id control has a value, then be certain that it is
displayed on your grid row -before- your radio control is displayed.

Here's how you should approach this...

1. For your a_radio control, go ahead and set up the properties to pull
your data, not worrying about any WHERE parameter for the question_id.

2. Add Custom Code to it's Before Build Select event:

//Just in case there are existing WHERE parameters.
if ($Component->DataSource->Where <> "") {
$Component->DataSource->Where .= " AND ";
}

//Pull by the row's question_id.
$Component->DataSource->Where .= "question_id=" .
CCToSQL($Container->DataSource->f("question_id"), ccsInteger);
beefcake

Posts: 9
Posted: 10/24/2016, 3:31 PM Quote message

Thanks DataDoIT.

Unfortunately could not get this to work with your suggestion above.

I got this working by adding the following in BeforeShowRow of the editable grid.

$tbl_SurveyQuestions->RadioButton1->DataSource->Where = "question_id=".
$tbl_SurveyQuestions->DataSource->question_id->GetValue();
$tbl_SurveyQuestions->RadioButton1->Prepare();


:-)
View profile  Send private message

Add new topic Reply to topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.