Yii Framework Forum: Ajax Implementation - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Ajax Implementation i have three drop down list one dependents on other Rate Topic: -----

#1 User is offline   vikram 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 24-June 09

Posted 22 July 2009 - 07:48 AM

see i have three dropdownlists let it be A,B,C.when A is selected B should be updated and when B is clicked C should be updated.the first i.e when A is selected B is updated but when B is the codes written for A is also executed and got displayed in the B what do i do do someone help me
thanks to the hearts that wishes to clear my doubt or to help me
vikram
0

#2 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 678
  • Joined: 29-November 08
  • Location:Paris, France

Posted 22 July 2009 - 08:39 AM

hi vikramsundar88,
an extension has been developed that could fit your needs ..
check http://www.yiiframew...ycascadeselect/
8)
0

#3 User is offline   vikram 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 24-June 09

Posted 24 July 2009 - 11:20 PM

View PostRaoul, on 22 July 2009 - 08:39 AM, said:

hi vikramsundar88,
an extension has been developed that could fit your needs ..
check http://www.yiiframew...ycascadeselect/
8)




i cant understand the extenision u specified...plz could u explain me further
thanks to the hearts that wishes to clear my doubt or to help me
vikram
0

#4 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 27 July 2009 - 09:02 AM

View Postvikram, on 24 July 2009 - 11:20 PM, said:

i cant understand the extenision u specified...plz could u explain me further

It's simple:
First code adds the JS lib.
After that you add a dropdownlist of your choice (the first one, not chained to anything)
Third step is to add chained dropdowns (to the previous dropdown) in 2 ways presented there.
"getdata" - name of the function/action which serves the data
"chainedid" - the id of the previous dropdown at which the current is connected

Last function is an example on what you serve. You can do the function as you want, but the string returned with ajax must be:
[{'Value':'v1','Text':'t1'},{'Value':'v2','Text':'t2'}]
What else to explain?
Paul
0

#5 User is offline   onemovieaday 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 14-June 10

Posted 14 June 2010 - 06:50 PM

View Postimasia, on 27 July 2009 - 09:02 AM, said:

It's simple:
First code adds the JS lib.
After that you add a dropdownlist of your choice (the first one, not chained to anything)
Third step is to add chained dropdowns (to the previous dropdown) in 2 ways presented there.
"getdata" - name of the function/action which serves the data
"chainedid" - the id of the previous dropdown at which the current is connected

Last function is an example on what you serve. You can do the function as you want, but the string returned with ajax must be:
[{'Value':'v1','Text':'t1'},{'Value':'v2','Text':'t2'}]
What else to explain?
Paul


Hi Paul/imasia,

I would like to ask for your help regarding this extension. I am just new to yii btw.
Anyhow, the issue is that after selecting a value from the first dropdown the second dropdown is stuck in the loading state (with the loading animation), please see attached screencap.

I have checked the response of the ajax call thru firebug and it seems to be OK:
[{'Value':'2','Text':'April 2011'},{'Value':'1','Text':'October 2010'}]

Here's the JS code generated:

*<![CDATA[*/
jQuery(document).ready(function() {
function commonTemplate(i) {return "<option value='" + i.Value + "'>" + i.Text + "</option>";};
jQuery('#Program_examScheduleId').cascade('#Program_course',{
ajax: {url: 'index.php?r=program/getdata' },
template: commonTemplate});
});
/*]]>*/

Thanks in advance!

Attached File(s)


0

#6 User is offline   onemovieaday 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 14-June 10

Posted 14 June 2010 - 08:38 PM

View Postonemovieaday, on 14 June 2010 - 06:50 PM, said:

Hi Paul/imasia,

I would like to ask for your help regarding this extension. I am just new to yii btw.
Anyhow, the issue is that after selecting a value from the first dropdown the second dropdown is stuck in the loading state (with the loading animation), please see attached screencap.

I have checked the response of the ajax call thru firebug and it seems to be OK:
[{'Value':'2','Text':'April 2011'},{'Value':'1','Text':'October 2010'}]

Here's the JS code generated:

*<![CDATA[*/
jQuery(document).ready(function() {
function commonTemplate(i) {return "<option value='" + i.Value + "'>" + i.Text + "</option>";};
jQuery('#Program_examScheduleId').cascade('#Program_course',{
ajax: {url: 'index.php?r=program/getdata' },
template: commonTemplate});
});
/*]]>*/

Thanks in advance!



Nevermind. I already figured it out. The problem was caused by a malformed JSON which in jQuery 1.4 the JSON data is parsed in a strict manner. So the following data:
[{'Value':'2','Text':'April 2011'},{'Value':'1','Text':'October 2010'}]
should be changed to:
[{"Value":"2","Text":"April 2011"},{"Value":"1","Text":"October 2010"}]

Thanks anyway.
0

#7 User is offline   sonam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 10-September 11

Posted 14 September 2011 - 07:07 AM

doesn't work for me please can u suggest this by using a regular way
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users