2

How to remove "200" and "Custom" in Item Per Page dropdwon? enter image description here

  • I answered to you, but community don't like my answer so i deleted it. I encourage users that give minus to comment or give own answer, like the SO rules says. – LucScu Nov 21 at 10:32
2

You need to create requirejs-config.js here in your custom module

app/code/SK/BackendUiHideCustomPerPage/view/adminhtml/requirejs-config.js

Content for this file is..

var config = {
    config: {
        mixins: {
            'Magento_Ui/js/grid/paging/sizes': {
                'SK_BackendUiHideCustomPerPage/js/grid/paging/sizes-mixin': true
            }
        }
    }
};

Now you need to create sizes-mixin.js file here in your custom module

app/code/SK/BackendUiHideCustomPerPage/view/adminhtml/web/js/grid/paging/sizes-mixin.js

Content for this file is

define([
    'ko',
    'underscore',
    'mageUtils',
    'uiElement'
], function (ko, _, utils, Element) {
    'use strict';

    var mixin = {
        defaults: {
            template: 'SK_BackendUiHideCustomPerPage/grid/paging/sizes',
            excludedOptions: ['200'],
        },

        initialize: function () {
            this._super();

            this.excludedOptions.forEach(function (exclusion) {
                delete this.options[exclusion];
            }, this);

            this.updateArray();

            return this;
        }
    };

    return function (target) {
        return target.extend(mixin);
    };
});

Now we will create template file here

app/code/SK/BackendUiHideCustomPerPage/view/adminhtml/web/template/grid/paging/sizes.html

Content for this file is

<div class="selectmenu" collapsible="">
    <div class="selectmenu-value" openCollapsible="">
        <input type="text" ko-value="_value" attr="id: index" autoselect/>
    </div>
    <button class="selectmenu-toggle" type="button" css="_active: $collapsible.opened" toggleCollapsible>
        <span translate="'Select'"/>
    </button>
    <div class="selectmenu-items" css="_active: $collapsible.opened" outerClick="discardAll.bind($data)">
        <ul>
            <li repeat="foreach: optionsArray, item: '$size'" css="_edit: isEditing($size().value)">
                <div class="selectmenu-item-edit" if="$size().editable" keyboard="13: updateSize.bind($data, $size().value, false)">
                    <input class="admin__control-text" type="text"
                        ko-value="$size()._value" hasFocus="isEditing($size().value)"/>
                    <button class="action-save" type="button" click="updateSize.bind($data, $size().value, false)">
                        <span translate="'Save'"/>
                    </button>
                    <button class="action-delete" type="button" click="removeSize.bind($data, $size().value, false)">
                        <span translate="'Delete'"/>
                    </button>
                </div>
                <div class="selectmenu-item">
                    <button class="selectmenu-item-action" type="button" text="$size().label" click="setSize.bind($data, $size().value)"/>
                    <button class="action-edit" type="button" if="$size().editable"
                        data-bind="
                            click: function () {
                                discardCustom().edit($size().value);
                            }">
                        <span translate="'Edit'"/>
                    </button>
                </div>
            </li>
        </ul>
    </div>
</div>
<label class="admin__control-support-text" translate="'per page'" attr="for: index"/>

You can download this module here

Now you need to run below commands

php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush

Output :

enter image description here

This will work for all grids in backend.

Hope this will work for you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.