I'd like to setup jquery pagination via ajax with the Pagination plugin. Unfortunately, I can't get the example to display more than one result (even after I change the items_per_page setting). How can I get this to work? Can downloaded from github.
It looks like the items_per_page setting is only used internally and doesn't affect how it displays the results
items_per_page
The number of items per page. The maximum number of pages is calculated by dividing the number of items by items_per_page (rounded up, minimum 1). Please note: This value is only for calculating the number of pages. The actual selection of the items correlating to the current page and number of items must be done by your code in your callback function! Default: 10
You will need to update this function if you want to increase the items per page using some kind of skip and take
function pageselectCallback(page_index, jq){
var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone();
$('#Searchresult').empty().append(new_content);
return false;
}
All this is doing is copying the element at the current page index i.e. 1-3.
Related
Wanted to get an idea on how to perform this task or my question.
I wanted to have a datatable where it retains the number of data per page and doesn't move data whenever there's changes.
Let's say I got 50 per page then I deleted two data on the first page which makes it 48. I clicked on page 2, the original first 2 data of page 2 was moved to the first page because of what I've deleted. What I wanted is that it shouldn't move and should stay on page 2. Then if I click on other pages, it should still retain first page 48, second page 50.
Hope you get my question.
Thank you in advance. :)
I don't know if it's possible to achieve that result, I wouldn't know how. But I suggest as a workaround that you set a property on each item, and then hide or show the item according to that property. This way the pagination counter remains the same.
In your controller:
$my_query_results = $query->paginate(50);
$my_query_results->each(function ($item) {
$item->visible = true||false; //check a condition here
});
I'm designing a BIRT report that should print on a form.
On this form there is a grid with a maximum of 4 lines of informations.
Think of it as an invoice form, whit a very restrictive place for listing products ordered.
My data set may return more than 4 rows.
In this case, I should print the remaining rows on another page.
My existing report was not designed to handle this case, which occurs not very often.
Now that I should deal with it, I have several questions :
Is it possible that a grid inserts a page break every x rows in the data set ?
There is a grand total to be displayed on the last page. What's the best way to deal with this situation ? With a footer ?
Thanks in advance.
Using a footer would be the default, and in most cases best, way to display a total.
You can specify page breaks on the Master Page. You could set it to break after a fixed length, or select the top four rows of the grid and set it break after that.
I'm trying to find a way to get the page number of a specific record.
This is my problem, after I add a new line I reload the grid, with sorting on, the new line can end up on any page. I need to be able to find the page number of that specific record, so I can navigate to its page and select it.
How can I do that, without having to load every page until I find it.
As I see to to accomplish where you would add a new record, reload the grid and then have that displayed page be the page where the new record would be found in a sorted grid. As a solution I think you would need to set the reloadAfterSubmit: false, and then generate your own reload where you would pass in (via postData) a value that would tell your controller to change the page of data to return to the jqGrid.
When the controller would receive a value in this field you would have to write some code to find which page of data the record would belong to and then pass that page to the jqGrid.
As the grid would be sorted, you could find where where that record would be in the sorted dataset and then grab that page. If you didn't have a very large dataset you could just iterate through every page till you found the page that would contain your result, but the method would depend on how large of dataset you would have. (Ex 5 pages of records, probably acceptable to just iterate through them all, as the dataset becomes larger you will have to look into fetching the proper page of data.)
I have a Jqgrid which has datatype as local. I am loading data at run time using addRowData, setCell. Every thing is working great. Note that I am not loading the entire data into grid so grid does not know how many pages are there. My server returns the count which I need to set it to the grid. The docs say that lastpage is ReadOnly? How do I set my last page(number of pages) to the grid? Any suggestions.
Thanks,
Sarath
The usage of addRowData method to fill jqGrid is the most old and the most ineffective way to fill the data in jqGrid. The problem is easy. If you place an element on the page the position of all other elements on the page have to be recalculated. It makes many resources of the web browser. The filling of the whole jqGrid body in one step is much more effectively especially with the large number of inserted rows. It's really needed to use addRowData method only in seldom cases.
Much more effective will be to use data parameter of jqGrid which allows to fill the grid with the data, sort the data corresponds to sortname and sortorder and display the first page where rowNum defines the number of rows per page. Additionally one should not use afterInsertRow callback and use gridview: true. In the case the filling of jqGrid is the most effective.
The number of pages of the grid will be calculated automatically based on the number of rows in the grid. Only if you use server side datatype ('json' or 'xml') the client part don't know the total number of pages and so one have to fill in the input data total, page and records together with the main data (see documentation). If one uses low level method addJSONData one can fill grid with the data and still set total, page and records to any values which you want.
Another way which you can use in some scenarios is datatype: 'jsonstring'. The data can be placed as the value of datastr option. By the way the value of datastr must be not only the JSON string but can be an object too.
I have a View (block display) listing node titles of a certain content type displaying the latest 12 published items. It displays underneath all nodes of a specific type.
What I'd like to do is be able to load the next 12 items with AJAX (I know the pager does this but I was hoping to avoid it) and also control the offset based on the node title.
I think the second request can be achieved with the row number in the query but so far I'm having trouble achieving a working script.
you always can call view results from Drupal API:
$results = views_get_view_result('my_view',$display, $args)
and in arguments you can pass start/end number of items, or something else, depends how you sorting your results
Well, instead of that work, how about selecting the mini pager? I'm pretty sure it only shows previous and next links. If it's not the exact display you want to use, you can override theme_views_mini_pager (from views/theme/theme.inc, line 636) to only show what you need.