CodeIgniter Forums

Full Version: pagination within grouped data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Hoopoe[/eluser]
This is an "in theory" question.

Take some tabs A, B with sub-tabs a1, a2 and b1, b2

a1, a2 are records, belonging to the category A: similarly for b1 etc.

Details are the values of the fields in each record.

A
- a1 > details
- a2 > details
B
-b1 > details
-b2 > details

I can envisage implementing pagination in each category i.e if total grouped records > greater than per-page, then show pagination as another <li> element.

The question I have is as follows:
If category A has enough records to require pagination, and I click the links to page#2 of the A records, what happens if I click on tab B if category B has no page#2 ?

Clicking on tab B would surely display an error.

My assumption is that I'd need some Javascript to do the following: whenever clicking on a category tab (A, B) rather than a record tab (a1, b1 etc), set the $start value for pagination to 0.

I'm aware this question is a bit abstract but would appreciate any thoughts anyone may have on the subject.

Hoopoe

El Forum

[eluser]jmadsen[/eluser]
@Hoopoe - pagination is driven off the url parameters, so you could just set up two sets of parameters, one for each tab. More realistically, since you are only looking at one tab at a time, you might just add a param value for which tab it should be applied to.

A you said, these days javascript would normally be your answer, but in theory you could run as many tabs separately as your url had character space for

El Forum

[eluser]Hoopoe[/eluser]
[quote author="jmadsen" date="1308373696"]@Hoopoe - pagination is driven off the url parameters, so you could just set up two sets of parameters, one for each tab. More realistically, since you are only looking at one tab at a time, you might just add a param value for which tab it should be applied to.[/quote]

I wonder if you have any examples of your idea...

Appending parameters to the hrefs in the category tabs sounds simpler than JS.

I am using Jquery tabbing, FYI.

If I have understood you, you're suggesting category tabs are like pagination links. Clicking them will run the pagination script using the parameter value.

But jQ tabbing depends on the href value referring to a div on the same page not a pagination method. Does that not stymie your idea ? The href can't reference a pagination method and a local div...

Hoopoe

El Forum

[eluser]jmadsen[/eluser]
no, you misunderstood me.

what I meant was, pagination typically runs off a set of parameters that get passed to the query to tell it which offset to apply. if you have two tabs, you have two queries - so, send two sets of parameters in your url.

more or less:

http://www.mysite.com/controller/functio...b2/offset2

tab1..to the end is dynamically built. there are some other params you typically need - no example in front of me, and no coffee yet :-p, but you get the idea

If you are doing it with jquery, you have anything and everything you want accessible, so just set up data attr, hiddens, whatever makes it easier

El Forum

[eluser]Hoopoe[/eluser]
[quote author="jmadsen" date="1308451846"]no, you misunderstood me.

if you have two tabs, you have two queries - so, send two sets of parameters in your url.

[/quote]

That's the nub of it. Thanks for pointing it out. I can't say that the overall problem seems particularly "simple" as a result, particularly if everything is dynamically constructed. But I see what you mean - your point has clarified the basic shape of the problem for me.

Hoopoe

El Forum

[eluser]Hoopoe[/eluser]
[quote author="jmadsen" date="1308451846"]no, you misunderstood me.

if you have two tabs, you have two queries - so, send two sets of parameters in your url.

more or less:

http://www.mysite.com/controller/functio...b2/offset2

[/quote]

Hi again,

The url you outline has multiple offsets - one for each tab. CI pagination seems to me to only allow one uri-segment to contain the offset. I am not sure how to marry CI Pagination with multiple uri_segments containing offset values...

Say you click on pagination links to display page 2 under tab#2. What's the trick to ensure tab#2 stays selected rather than the default e.g tab#1 ?

El Forum

[eluser]jmadsen[/eluser]
sorry, it's been a while since i wrote this and i don't quite remember what i was outlining, but I thought i was describing two separate tabbing systems. you want pagination on each a paginated tab?

I think you'll need to load two instances of the pagination class for that - that's where I would start looking

El Forum

[eluser]Aziz Chouhan[/eluser]
hello dear
as per i read the discussion i think that you are using the jQuery and ajax tabs for ur data showing for two different categories.
in the tabs either u can show all data at one page of number of records, or you can show top 5 or 10 records at a time , and show the more... link at the footer of the tab.

but in case if you want to crate the pagination for showing data , i think that you need
Quote:ajax and jquery pagination
for completing your requirement.when one click on pagination link the next data will fetch direct from server without refreshing the complete page.and you get next category data.

if you have any problem ,reply
i will show you the complete solution
enjoy

El Forum

[eluser]Hoopoe[/eluser]
[quote author="Aziz Chouhan" date="1310910947"] you can show top 5 or 10 records at a time , and show the more... link at the footer of the tab.

but in case if you want to crate the pagination for showing data , i think that you need
Quote:ajax and jquery pagination
for completing your requirement.when one click on pagination link the next data will fetch direct from server without refreshing the complete page.and you get next category data.

if you have any problem ,reply i will show you the complete solution
enjoy[/quote]

Aziz - there's no Ajax in my setup, only Jquery tabbing. I am using nested tabs. The categories are li elements corresponding to div elements. Each div element has another <ul> composed of the category members, with corresponding divs containing the data or details.So the structure is-
<ul>
<div>
--<ul>
--<div>

Basically, this is now set up WITHOUT pagination. I'd like to introduce pagination.

I can generate the pagination links corresponding to each category. And I can get the so-called base_url to display the appropriate combination of category id and offset.

And I have got functioning code to correctly process the category id and offset relayed in the end segments of the base_url . I still need some jquery (probably) to preventing clicking on pagination links displaying the default tab data.

Presumably that jquery solution would use the category id data passed in the base_url to designate which tab is assigned the class 'selected'

It would be interesting to see your Ajax/Jquery pagination solution.

regards,

Hoopoe