Communication between widgets without writing JS code in the view

Hello everyone !

I am new in yii framework and I am in front of a big project. I am about to make a decision regarding framework I am supposed to use and I have a "thing" which is not yet clear to me regarding Yii. I wonder if it is possible to write business logic using data from Ajax widgets at controller level. To be more specific in my problem I will give you the following example. I have also researched into PRADO and there I have found this functionality very interesting:

Having this code in Home.page




<html>

<body>

<com:TForm>

	<com:TActiveButton ID="myButton" Text="Button Text" OnClick="buttonClicked" />

	<com:TActiveCheckBox ID="myCheck" Text="Check Text" OnCheckedChanged="checkboxClicked"/>

</com:TForm>

</body>

</html>



and this code in Home.php




<?php

Prado::using('System.Web.UI.ActiveControls.*');

class Home extends TPage

{

	public function buttonClicked($sender,$param)

	{

		$this->myButton->Text = "Hello World";

	}

    public function checkboxClicked($sender,$param)

    {

		$this->myCheck->Text = $this->myButton->Text;		

    }

}

?>



… I can access properties of one control which is "myButton" in another ajax control event "myCheck". As you can see in the above example, I have 2 ajax controls, and when I click on the ajax checkBox I can access the other ajax control text property. So for this reason, I do not need to write javascript code in the .page to get the button text property, and i can have the .page clean, and all the code is moved in the .php page.

My project is supposed to have a chart, and then a lot of filters (checkboxes, text and dropdowns). As soon as one of the filters is changed the chart info is supposed to change. My objective is to use Ajax controls but to write the functionality in the .php file (controller in yii case) in order to retrieve the correct data using the model. I want to avoid a page refresh (I have read about the statefulForm) because this chart is just a small part of a page and I want to avoid recalculation of all the other page sections to improve performance.

I have tried to achieve this functionality using page code JS but because of complexity the page code is becoming a mess.

So…the question is, can I achieve this functionality using Yii ?

If I have for example a CJuiDatePicker and a CJuiButton on my view, can I set the CJuiButton Text with the selected CJuiDatePicker date, on the CJuiButton click event without refreshing the page and without writing JS code … ? something similar with what I have already achieved using PRADO ?

Thank you very much .

Alin

A bump for this topic, anyone knows the answer?

Hello… anyone knows if this is possible with YII ?