use executesql results in grid

75 views
Skip to first unread message

Yufei Li

unread,
Apr 14, 2014, 12:35:06 PM4/14/14
to web...@googlegroups.com
I am doing a quite complicated sql select with selects nested, which I do not know how to create using DAL, so I decided to go with executesql with fields specified. My questions is once I get back results of <class 'gluon.dal.Rows'> type, is there a way to create a SQLFORM.grid with them? I am able to use SQLTABLE, but I would lose the inline editing ability as suggested in
http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript

Thanks

Johann Spies

unread,
Apr 15, 2014, 1:18:26 AM4/15/14
to web...@googlegroups.com

On 14 April 2014 18:35, Yufei Li <ymz...@gmail.com> wrote:

I am doing a quite complicated sql select with selects nested, which I do not know how to create using DAL, so I decided to go with executesql with fields specified. My questions is once I get back results of <class 'gluon.dal.Rows'> type, is there a way to create a SQLFORM.grid with them? I am able to use SQLTABLE, but I would lose the inline editing ability as suggested in
http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript

What I do is to either create a database view or a table containing the result and then in the controller define a model with 'migrate = False'  to read the view/table and then use the grid on that view/table.  In order for web2py to use that view/table easily I put something like 'id = 1'  in the select and then make the id field 'readable=False'  in the controller.

Regards
Johann
--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Niphlod

unread,
Apr 15, 2014, 6:32:31 AM4/15/14
to web...@googlegroups.com
yep but valid only for read-only grid. You need a unique integer value to use the grid for editing purposes
Reply all
Reply to author
Forward
0 new messages