How add grid table in custom page?

I want to add table in custom page
I tried this code but it is not working:

page.add_field({
fieldname: “table”,
label: __(“Grid of user”),
fieldtype: “Table”
});

I get this error:
Uncaught TypeError: Cannot read property ‘perm’ of undefined

it seems the grid only supported for form?! Am I correct?
How I can use it with page?

Regards

@Mohammed_Redha, GridTable aren’t designed to work outside of forms.

You need create a extended widget from the frappe.ui.form.ControlTable providing all missing arguments, from the page.

So, basically you need that your page emulates the same behavior of a Form, that is not easy to reach!

2 Likes

Thank you for your reply

Hi @Mohammed_Redha
I would like to ask if you have a solution for that issue?
need your help plz
Thanks
Mayaa

Hi guys,
I always advise to use single doctype rather than pages as single doctype can fulfil the functionality of the page, moreover you will get the advantage of the form view components such as frappe form grid tables and you can also easily expand other external JS libraries for specific doctype by using hook and link these libraries functions with the HTML docfield, and I already done such thing by using a single doctype, as @max_morais_dmm said it needs some hustle to extend the frappe grid table for pages, so if you use single doctype and customize it as you need by using form functions for example: disabling save action and create your own custom buttons and exploit its table grid views, or may expanding the JS scripts you do end up not reinvent the wheel.

hope that helps

3 Likes

@ahmed-madi
This is like my approach :+1:, You can convert any single doctype to be as a page and use the grid as you like :slight_smile:

1 Like