Ajax Pagination On Ajax Called Datagrid

Hi,

I fetch a Yii datagrid using JQuery.ajax method. I pull it from the server but the ajax pagination is not working on the datagrid.

Is there a way to get it working?

James.

Hi,

You pull the data by an ajax call while rendering the view render it partially and update the content to a specific division.

If you share your code i can given an example with yours.

Hi,

The view is rendered partially, but its not pulling in the necessary JS to make it work. The JS normally goes at register script footer etc.

Anyways here is the code …




public function actionCompetencyDataGrid($job_family_id) {

			

	$job_family_competency_data = new CActiveDataProvider(JobFamilyCompetency::model()->belongsToJobFamily($job_family_id), array("criteria" => array("order" => "sort_order")));

			

	echo $this->renderPartial("//jobfamilycompetency/_job_family_competency_table", array("data" => $job_family_competency_data), true);

			

}



Thanks.

Hi,

I think you are echoing the renderPartial don’t echo it just call it

$this->renderPartial("//jobfamilycompetency/_job_family_competency_table", array("data" => $job_family_competency_data), true);

all the scripts that are required to run the data-grid will be included. if it is not successful then add like this way.


public function actionCompetencyDataGrid($job_family_id) {

        $this->layout='//';


        $job_family_competency_data = new CActiveDataProvider(JobFamilyCompetency::model()->belongsToJobFamily($job_family_id), array("criteria" => array("order" => "sort_order")));

                        

        $this->render("//jobfamilycompetency/_job_family_competency_table", array("data" => $job_family_competency_data));

                        

}

Let me know if it solves the problem.

Ok thanks will try to implement, and let you know.

Tried this and its getting close.

It now works except when clicking on the pagination page i.e. second page, third page etc.

It is repeating the datagrid rather than replacing the old one.

Any ideas?




public function actionCompetencyDataGrid($job_family_id) {

			

			$this->layout = "//";

			

			$job_family_competency_data = new CActiveDataProvider(JobFamilyCompetency::model()->belongsToJobFamily($job_family_id), array("criteria" => array("order" => "sort_order")));

			

			echo "<h4>Competencies for " . JobFamily::model()->findByPK($job_family_id)->name . "</h4><br />";

			echo CHtml::link("Add competency", array("jobfamilycompetency/create/job_family_id/" . $job_family_id)) . " | ";

			echo CHtml::link("Reorder competencies", array("jobfamilycompetency/reorder/job_family_id/" . $job_family_id));

			echo $this->render("//jobfamilycompetency/_job_family_competency_table", array("data" => $job_family_competency_data));

			

		}