jstockdale
(Joshdstockdale)
March 11, 2011, 9:45pm
1
I’m trying to extract the data from my CActiveDataProvider to put into a JQuery grid but I can’t seem to figure out how to do that. Here is my feeble attempt:
$data = $model->search();
foreach($data->getData() as $d){
$script .= 'var mydata = [
{prop_id:"'.$d->prop_id.'"},
]; ';
}
besnik
(Besnik78)
March 12, 2011, 12:04am
2
Add
die(print_r($script,true));
after your code to see your error.
You will need to try something similar to this.
$dataProvider = $model->search();
$list = array();
foreach($dataProvider->getData() as $model){
$list[] = '{prop_id:"'.$model->prop_id.'"}';
}
$script = 'var mydata = [' . implode(',',$list) . ']; ';
jstockdale
(Joshdstockdale)
March 14, 2011, 1:52pm
3
Awesome! Worked perfectly. Thanks a lot.