-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination with 1 item per page breaks breaks when using prev/next #11231
Comments
Just to clarify, when you say "prev/next", is that the "previous page" and "next page" buttons in the paginator when you're viewing the |
Also your "how to reproduce" is just some code without context. Please give some steps along with the code, so it's easy to reproduce by just following some steps. Especially double check the code since you mention 1 item per page, but the code shows 2. |
Updated the how to reproduce. It's when using the detail form using the prev/next arrow next to the delete button |
I cannot replicate on 5.2.x-dev or 5.x-dev Please let me know exact version and exact code used Here's the code I failed to replicate with: // app/src/MyModelAdmin.php <?php
use SilverStripe\Admin\ModelAdmin;
class MyModelAdmin extends ModelAdmin
{
private static $url_segment = 'MyModelAdmin';
private static $menu_title = 'My model admin';
private static $managed_models = [
MyDataObject::class,
];
} // app/src/MyDataObject.php <?php
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\GridField\GridFieldPaginator;
class MyDataObject extends DataObject
{
private static $table_name = 'MyDataObject';
private static $db = [
'Title' => 'Varchar'
];
private static $many_many = [
'MySubDataObjects' => MySubDataObject::class
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
$gridField = new GridField('MySubDataObjects', 'MySubDataObjecs', $this->MySubDataObjects());
$config = GridFieldConfig_RecordEditor::create();
$gridField->setConfig($config);
$paginator = $config->getComponentByType(GridFieldPaginator::class);
$paginator->setItemsPerPage(1);
$fields->insertAfter('Title', $gridField);
return $fields;
}
} // app/src/MySubDataObject.php <?php
use SilverStripe\ORM\DataObject;
class MySubDataObject extends DataObject
{
private static $table_name = 'MySubDataObject';
private static $db = [
'Title' => 'Varchar'
];
private static $belongs_many_many = [
'MyDataObjects' => MyDataObject::class
];
} |
here is a video maybe it's better: Silverstripe---MyModel.mp4it's on silverstripe/framework 5.2.6 using chrome/windows |
OK thanks that video helps a lot I've done some debugging, looks like in the The full url of my request is |
yes, so while my issue (who would be using 1 item per page :) ) is pretty minor, i'm sure it leads to a larger issue that could cause tricky bugs maybe related: |
Apparently we might look at a new way of managing the gridstate, so in the mean time I might just park this one for a wee while since it seems like it's very hard to fix |
Module version(s) affected
5.x
Description
Stumbled upon this recently when doing some tests
When having a nested gridfield in a model admin, if you have setItemsPerPage = 1 for the nested grid field, when using the next arrow, it stops working after three clicks, as if there was no record anymore
Eg: i have 9 pages
It stops on record number 3
It works just fine with 2 items per page
Refreshing the page doesn't help
I guess something is wrong with the +1/-1 offset logic
How to reproduce
Possible Solution
No response
Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)The text was updated successfully, but these errors were encountered: