DataTables change pagination prev/next button of laravel backpack - laravel

I use https://backpackforlaravel.com/
by default, it shows :
but i want applying it : Previous 1 2 3 4 5 ... 10 Next on all pages .
i don't see < or >. Thank you in advance

Related

Strapi - GraphQL - Issue on sorting and paginating

I’ve had an issue using Strapi when I try to combine sorting and pagination on my GraphQL requests from a NextJS front. Basically, I am trying to query the backend to fetch all records sorted by creation date from the newest to the latest, and THEN paginate them.
My issue is : the pagination occurs BEFORE the sorting. Example :
If I have 4 docs like so :
- Document 1
- Document 2
- Document 3
- Document 4
I want them sorted by date and 2 by page, which would give me :
Page 1
- Document 4
- Document 3
Page 2
- Document 2
- Document 1
But I have this instead :
Page 1
- Document 2
- Document 1
Page 2
- Document 4
- Document 3
My query looks like this :
query getDocuments {
documents (
sort:"updatedAt:asc"
pagination: {page: ${page}, pageSize: 10}
){
meta {pagination {total page pageCount}}
data {
id
attributes {
name
category
updatedAt
creator {data {attributes {username}}}
}
}
}
}
It paginates first, then sorts. Did you observe this behavior ? Is it intended ? Is it GraphQL itself working this way or Strapi ?
Thanks in advance !

how would I add index to all returned results when using pagination

I want to give index to each result from a query, something like this
page 1
1
2
3
4
5
page 2
6
7
8
9
10
page 3
etc
How would I do that? I can't use the id from the table, and I can't use $loop->iteration to print out a the index for each result, since loop->iteration would reset for each page load if I am correct?
How would I give index to all returned results and have it work accors all the pages
You can use $loop->iteration and pagination instance methods:
($results->currentPage() - 1) * $results->perPage() + $loop->iteration

Laravel 5.2 pagination + infinite scroll duplicates

I encountered a problem with pagination in my Laravel app.
Normally, when I want to use Laravel pagination with let's say 3 rows for one page, I use Eloquent method paginate/simplePaginate in combination with method latest() like so:
//MyController.php
$posts= Post->latest()->paginate(3);
//MyView.blade.php
#foreach ($posts as $post)
{{ $post->id }}
#endforeach
{{ $posts->links() }}
So when i have 6 posts in my database and I use Laravel pagination + Infinite scroll, that becomes:
6
5 (1. page)
4
--- ('page separator')
3
2 (2. page)
1
But, if user inserts new row into database table before I reach page 2,
the collection shifts and second page of data becomes:
6
5 (1. page)
4
--- POST WITH ID 4 IS DUPLICATED BECAUSE OF SHIFT IN COLLECTION
4
3 (2. page)
2
So, for example --- if user inserts three new rows into database before I reach paginator, then the second page will output the same three table rows as my current first page, but i'd like to output the remaining table rows:
6
5 (1. page)
4
--- AT SOME TIME BEFORE PAGINATION WAS TRIGGERED, POST WITH ID '7' HAS BEEN ADDED
3
2 (2. page) - continues normally with remaining rows (pagination ignores newly added row)
1
Is there any workaround for this problem?
Thanks.
I solved this issue by asking for the first record id of the first page served
// {initial query} $records->orderBy('created_at', 'desc');
if(is_int($last_id)){
$records = $records->where('id', '<=' , $last_id);
}
$records = $records->paginate($per_page);
This way, the paginator get's records starting from that id, ignoring new records
You could try this:
$posts= Post->orderBy('id', 'desc')
->distinct()
->paginate(3);

Pagination class in Custom Module in joomla

I am developing one custom search module in joomla. so I am using joomla's in-built database connection and function.
Problem is that I want to use pagination class in this module but don't know any hint.
Please help me on this.
Thanks.
Step 1: Get the total number of items in your database
ex: select count(*) from #__some_table where ....
Step 2: Import joomla pagination and create pagination object
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
where
$total = total number of items that you count in step 1
$limit = total number of items you want to display on a page
$limitstart = index of the first item in the page. For example if you have 20 items per page, 0 is start index for 1 page, 20 is start index for second and so on.
Step 3: Show pagination on your page
echo $pagination->getPagesLinks();
echo $pagination->getPagesCounter();

Simple binding questions

I am trying a simple application which is like this-
View:
A table view showing count of entity 1 in first column and count of entity 2 in second column. Here each row specifies count of different entities at a particular date.
A text field showing- total count of entity 1 multiplied by 35.
A text field showing- sum of count of entities in both the columns.
eg.
(entity1) (entity2)
<2> <3>
<4> <2>
<5> <7>
requirement 1: text field specified in
pt. 2 should show - 385 ie. (11 * 35)
requirement 2: text field specified in
pt. 3 should show - 23 ie. (11 + 12)
Model:
An object with two properties:
int entity1Count
int entity2Count
I am using an array controller object to show data in table view.
My question is -
Can I implement my requirements via
bindings in IB? If yes then how?
Thanks,
Miraaj
I am able to implement requirement 1, via bindings in IB using NSNumberFormatter and its multiplier property :)
but I am still unable to implement requirement 2 :(
Any suggestion ?
Thanks,
Miraaj

Resources