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
});
Related
I have a model which contains a list of items.
The list will have no more than 100 items.
Hence, I grab this list in one hit when I grab the model.
I want to be able to create / edit this model in a view that has pageination on it.
If I have for instance 20 items in my list and a page size of 5 I see 4 pages. I find that when editting on any page other than 1 my models list comes though to the Action as null.
If I am on page 1, the models list only has 5 items.
I understand why this is, but I cannot figure out how to get round this without posting my model in chunks.
Is there a way I can do what I want, which is to post the model in 1 hit from a view that has pageination on it?
Not sure on the downvote - but I seem to have got there in the end.
I call this function to expand the table to show all rows before submitting.....
function expandTable() {
var oTable = $('#tblCategories').DataTable();
oTable.page.len(250).draw();
};
.....my model makes it through to the action intact with ALL of the list items present.
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 want to know where and how does magneto store the data to maintain grid filter and mode type. Like I go to listing page and select list mode while displaying five records and then goes to other page of the same site and comeback. It shows me my previous grid mode and records. I display $_REQUEST, but doesn't see anything there. Anyone knows how I can get those values?
Magento store limit,order,direction in Mage::getSingleton('catalog/session').
If limit,order,direction is found in REQUEST then new value is set in Mage::getSingleton('catalog/session') .
You can check getLimit(),getCurrentMode(),getCurrentOrder(),getCurrentDirection() function in the class
app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php
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.
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.