Anyway to override the current page-length of 50 rows in ChildTables

Is there any way I could customize the page length of frappe GridTables?

I know the price (in terms of performance) I have to pay to show more than 100+ tables but it’s worth it for our implementation, I would love to completely disable pagination or just increase the limit to 500 or more.

1 Like

I’m looking for this too.

Although the paginated view is good for page loading, problems arise when an existing row needs to be edited. There is no quick way for the user to search for/go to a particular row to edit it. In some cases we have over 20 “pages” which need to be manually searched to get to the row we are looking for where previously we could just use Ctrl/Cmd + F to look for it.

2 Likes

Frappe team, please look into it :pleading_face:

From my naive understanding, this file is what you are looking for:

Hi…I believe the easiest way to accomplish this is via Client Script. For example, for Customize Form, I added this:


    frappe.ui.form.on("Customize Form", {
        refresh: function(frm) {
            cur_frm.fields_dict.fields.grid.grid_pagination.page_length = 250
            cur_frm.refresh_fields('fields')
        }	
    })

Hope this helps :grinning:

3 Likes

tested in version 13.21, it does not work.

I am pretty sure it works. Post screenshots to see if I can help you spot the problem

would like to ask other user to try. per my knowledge on studying the standard code, it will not work .

So there is a way…

One way is to just hook events for each particular doctype, loop over frm.grids, set the grid.grid_pagination.page_length to 10000, .page_index to 1 and .total_pages to 1, and then call .render_pagination (all on the grid.grid_pagination object) and possibly call frm.refresh(). That’s the solution above (but I think sometimes you need to set page_index and/or total_pages and/or call render_pagination(); I haven’t played with it a lot).

I have worked out how to override this for all forms, but it is horrific hackery of the worst kind :stuck_out_tongue: In a custom app, add a JS file that runs for everything in hooks.py (app_include_js). Then have something like:

if (!frappe.ui.form.ControlTable.prototype._make) {
    frappe.ui.form.ControlTable.prototype._make = frappe.ui.form.ControlTable.prototype.make;
    frappe.ui.form.ControlTable.prototype.make = function() {
        this._make();
        if (!this.grid.__proto__._setup_grid_pagination) {
            this.grid.__proto__._setup_grid_pagination = this.grid.__proto__.setup_grid_pagination;
            this.grid.__proto__.setup_grid_pagination = function() {
                this._setup_grid_pagination();
                if (!this.grid_pagination.__proto__._setup_pagination) {
                    this.grid_pagination.__proto__._setup_pagination = true;
                    this.grid_pagination.__proto__.setup_pagination = function() {
                        this.page_length = 1000;
                        this.page_index = 1;
                        this.total_pages = Math.ceil(this.grid.data.length/this.page_length);

                        this.render_pagination();
                    }
                    this.grid_pagination.setup_pagination()
                }
            }
        }
    }
}

Replace the page length of 1000 above with your choice (or set it using a boot session or whatever).

I first noticed this in Customize Form, where it annoyed me (but not enough to do anything about it), then I got complaints from the staff from other DocTypes so I have designed this work-around.

This would have been a lot easier if Frappe had just made it user-configurable instead of a magic number buried in a class which is really hard to access… I realise it would be a very easy Pull Request to shift it to a setting somewhere so I shouldn’t moan too much without actually doing something about it!

1 Like

Didnt work for me. I am creating a new DocType with 150+ fields. After 50 it gets paginated. Not possible to drag a fieldfrom page 1 to page 2 . Anyway of doing it?

In detail dialog click “Move” where you can specify row no.