beefcake
Posts: 11
|
Posted: 10/21/2016, 6:33 PM |
|
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.
|
|
|
DataDoIT
|
Posted: 10/22/2016, 7:25 AM |
|
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: 11
|
Posted: 10/24/2016, 3:31 PM |
|
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();
|
|
|
|