best practice for CListView with CJuiDialog in CJuiTab with Ajax

Hi,

since days my development stagnantes and I hope to get help here.

I have 1-n data models. Each model is based on tables of a MySQL Database.

Each model should be rendered in an CListView and each CListView is placed into a separate tab in a CJuiTab. (pagination is active)

In addition, a CJuiDialog should open (useing AjaxLink) if you select an entry (row) on the CListView.

Content of the CJuiDialog is detail information of the selected row, which are loaded into the CJuiDialog using ajax.

And I have those problems.

  1. strange behavior when I change between the tabs. CJuiDialog only opens on the first tab, not in the second or n-th, Tab but the Ajax request works (gets the data for CJuiDialog).

  2. every time I switch between the tabs, the number of Ajax request increases by 1 if 1 CJuiDialog is opend/if 1 AjaxLink is clicked.

Example: I change 3 times between tab1 and tab2. Then i click a row in tab2 to open a CJuiDialog. Four Ajax requests were sent, but no CJuiDialog opens (see 1)

Right now I’m thinking of dropping CJuiTab and Ajax in order to fill static CListView Content into the tabs. But it’s an performance issue to render all the conent of all the tabs, regardless whether the user activated / look inside the tab or not.

So what is best practice for this? How to continue?

Looking forward to help.

thanks very much.

Hi there,

In order to avoid what happened to you I developed my own pagination and I code the links the way I wanted. Here is the article that explains how I did it: http://www.ramirezcobos.com/2010/10/04/how-to-create-a-custom-pagination-widget-for-yii-framework/ . You can create your own and change the links to make a call to external JS function that is the one responsable for the AJAX calls. This technique works like a charm on my case, maybe there is an easier solution but that I do not know yet

After, to open dialogs, you have to code the links on the _view responsable to display the list of elements in the CListView. Having AJAX being controlled by an external JS (rendered on one of the layouts) and out of the AJAXed content of the CListView, you wont have to worry about the recurring binded events.

Thanks for the link to the tutorial.

I have read it carefully.

Very interesting, how easy you can build a widget.

Where (in the code) do I add this widget, to use it with CListView?

What is about this:

"I promise I will discuss how to create a table widget in the next post"

Because: CListView seems my problem.

In addition, I currently use CListView in modified form.

I can not handle all the records of a table with CActiveDataProvider (there are to much)

Therefore, the data provider receives (from the database) only the records for a single page. (for example: 25 rows)

To get pagination work I set $model-> setTotalItemCount to the number of search results. (for example: 542789)

This means to me, that Ajax with CListView is a major construction site. I think, my present state of knowledge is not comprehensively enough.

merry christmas :slight_smile:

[b]

Where (in the code) do I add this widget, to use it with CListView?

[/b]

About using your widget PAGER on your CListView is by setting its property ‘pager’ when you render it. Set its property ‘pager’=>‘application.whereverfolderIputmywidget.mywidgetname’

[b]

What is about this:

"I promise I will discuss how to create a table widget in the next post"

[/b]

You got me there! I will :)

[b]Because: CListView seems my problem.

In addition, I currently use CListView in modified form.

I can not handle all the records of a table with CActiveDataProvider (there are to much)

Therefore, the data provider receives (from the database) only the records for a single page. (for example: 25 rows)

To get pagination work I set $model-> setTotalItemCount to the number of search results. (for example: 542789)

[/b]

I know perfectly where you are going there, I am at the moment building a new system now, and I have a huge cities database. Even though I have good knowledge on how to handle this, is a bit hard to fit within the boundaries of the CMS.

[b]

This means to me, that Ajax with CListView is a major construction site. I think, my present state of knowledge is not comprehensively enough.

[/b]

dont give up, keep on going… big problems comes with big research, which turns into good knowledge

[b]

mary christmas :slight_smile:

[/b]

Merry Xmas to you too :)

The same question comes to me. It seems the css and js were duplicated loaded using renderPartial. Who can help me ?