Yii Framework Forum: Ajax Pagination On Ajax Called Datagrid - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Pagination On Ajax Called Datagrid Rate Topic: -----

#1 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 444
  • Joined: 18-November 10
  • Location:UK

Posted 25 July 2013 - 03:51 PM

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.
0

#2 User is offline   Yureshwar Ravuri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 30-November 11
  • Location:Hyderabad

Posted 26 July 2013 - 05:51 AM

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.
--------------------------
Thanks,
Yureshwar Ravuri
Mail: yureshwar@yuresh.net
Web: http://www.yuresh.net
0

#3 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 444
  • Joined: 18-November 10
  • Location:UK

Posted 26 July 2013 - 05:57 AM

View PostYureshwar Ravuri, on 26 July 2013 - 05:51 AM, said:

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.
0

#4 User is offline   Yureshwar Ravuri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 30-November 11
  • Location:Hyderabad

Posted 29 July 2013 - 04:05 AM

View PostJamesBarnsley, on 26 July 2013 - 05:57 AM, said:

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.
--------------------------
Thanks,
Yureshwar Ravuri
Mail: yureshwar@yuresh.net
Web: http://www.yuresh.net
0

#5 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 444
  • Joined: 18-November 10
  • Location:UK

Posted 30 July 2013 - 03:43 AM

View PostYureshwar Ravuri, on 29 July 2013 - 04:05 AM, said:

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.
0

#6 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 444
  • Joined: 18-November 10
  • Location:UK

Posted 06 August 2013 - 06:26 AM

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));
			
		}

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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