beamsjr  
          
              
                August 31, 2011, 12:30pm
               
              1 
           
         
        
          I am trying to use a gridView to display the Sites that belong to a company, In the View.php of controllers I have added:
	$this->widget('zii.widgets.grid.CGridView', array(
		'dataProvider'=>new CActiveDataProvider($model->sites, array()),
		'columns'=>array(
			'SITE_NAME',
			),
		));
My controller has
	public function actionView($id)
	{
		$this->render('view',array(
			'model'=>$this->loadModel($id),
		));
		
	}
If I do a for each on the model->sites I am able to echo the SITE_NAME, so I know the relation is working. I do not get any errors, but it looks like CSS does not load and I just get " Viewing Company" at the top of the page.
I am new to obj programing, and Yii, so I am not quite sure of what im doing…  Any help would be appreciated!
         
        
           
         
            
       
      
        
        
          The dataprovider property expects an IDataProvider (usually a CActiveDataProvider). I usually do something like this.
dataProvider = new CActiveDataProvider('Site', array(			// Finds all sites with a matching parent company
                'criteria' => array(
                    'condition' => 'company_id=:companyId',
                    'params' => array(
                        ':companyId' => $model->id, 			// The id of the parent company
                    ),
                    'order' => 'create_time DESC',
                ),
                'pagination' => array(
                    'pageSize' => 10,
                ),
            ));
			
$this->render('company/sites', array(
            'dataProvider' => $dataProvider,
        ));
Cheers,
Matt
 beamsjr:
 
I am trying to use a gridView to display the Sites that belong to a company, In the View.php of controllers I have added:
	$this->widget('zii.widgets.grid.CGridView', array(
		'dataProvider'=>new CActiveDataProvider($model->sites, array()),
		'columns'=>array(
			'SITE_NAME',
			),
		));
My controller has
	public function actionView($id)
	{
		$this->render('view',array(
			'model'=>$this->loadModel($id),
		));
		
	}
If I do a for each on the model->sites I am able to echo the SITE_NAME, so I know the relation is working. I do not get any errors, but it looks like CSS does not load and I just get " Viewing Company" at the top of the page.
I am new to obj programing, and Yii, so I am not quite sure of what im doing…  Any help would be appreciated!
 
 
         
        
           
         
            
       
      
        
          
          
            beamsjr  
          
              
                August 31, 2011,  1:13pm
               
              3 
           
         
        
          Thank you so much, that did the trick!
         
        
           
         
            
       
      
        
          
          
            beamsjr  
          
              
                August 31, 2011,  6:51pm
               
              4 
           
         
        
          Ok, Now I am starting to feel really dumb…  When You click on a site I have it linked to go to the info’s view,
'viewButtonUrl'=>'Yii::app()->createUrl("/info/view", array("id" => $data->ID_SITE_PK, "site" => $data->SITE_NAME))',
Which works great, however I also want to send over the company name as well so I can fix the breadcrumbs $model->COMPANY_NAME, which would look like this:
'viewButtonUrl'=>'Yii::app()->createUrl("/info/view", array("id" => $data->ID_SITE_PK, "company" => $model->COMPANY_NAME, "site" => $data->SITE_NAME))',
When I do this i get an error, Where does the $data object come from and how can I do this?
         
        
           
         
            
       
      
        
          
          
            tri  
          
              
                August 31, 2011,  7:28pm
               
              5 
           
         
        
          
 beamsjr:
 
Ok, Now I am starting to feel really dumb…  When You click on a site I have it linked to go to the info’s view,
'viewButtonUrl'=>'Yii::app()->createUrl("/info/view", array("id" => $data->ID_SITE_PK, "site" => $data->SITE_NAME))',
Which works great, however I also want to send over the company name as well so I can fix the breadcrumbs $model->COMPANY_NAME, which would look like this:
'viewButtonUrl'=>'Yii::app()->createUrl("/info/view", array("id" => $data->ID_SITE_PK, "company" => $model->COMPANY_NAME, "site" => $data->SITE_NAME))',
When I do this i get an error, Where does the $data object come from and how can I do this?
 
 
Try this
'viewButtonUrl'=>'Yii::app()->createUrl("/info/view", array("id" => $data->ID_SITE_PK, "company" => '.$model->COMPANY_NAME.', "site" => $data->SITE_NAME))',
/Tommy
         
        
           
         
            
       
      
        
          
          
            beamsjr  
          
              
                September 1, 2011,  7:06pm
               
              6 
           
         
        
          That almost worked, got me on the right track though… I had to add "" around that.
'viewButtonUrl'=>'Yii::app()->createUrl("/info/view", array("id" => $data->ID_SITE_PK, "company" => "'.$model->COMPANY_NAME.'", "site" => $data->SITE_NAME))',
Thanks again!