How to working with Drop Down List and Cgridview With Ajax call!

Hi, I’d supposed if I got a drop down list and cgridview.

When I make a choose in drop down list, the cgridview’s data will filter by ajax call in drop down list.

Cause when I use the usually ways to filter data in cgridview, It’s also work, but the value which I choice in drop down list lost focus.

In case if I make an ajax calling with the drop down list, the ajax function request the return value, how can controller return data type, how can I fetch the data into cgridview. Is it somethings wrong in my deduces?

Any idea?

Thanks :rolleyes:

I’m not sure I understand what you want to do. Do you mean the choice you’ve made will not be reflected in the updated grid? It should be if you saved the data. The dropdown will be initialized to the value of $data->some_attribute on return. So if value_for_some_attribute #n is returned in the model it should show up in the dropdown field.




'value'=>'CHtml::activeDropDownList(

  $data,

  "some_attribute",

  array(

    "value_for_some_attribute #0"=>"presentation #0",

    "value_for_some_attribute #1"=>"presentation #1",

    "value_for_some_attribute #2"=>"presentation #2",

  )

)',



/Tommy

I’m so sorry, the above code isn’t my mean. anyway, thanks for replay.

Let me make an example to illustrate:

Suppose I have 2 tables: student and class.

In my layout, I’ll display list of students by cgridview. But sometimes, I wanna filter students by class through drop down list.

When class was choose, the cgridview will be load, and students in cgridview must match the class value which I chose (I wanna do this job with ajax tech) :rolleyes:

Thanks :lol: