[web2py] Re: how to keepvalues in SQLform.grid search form after submission

2018-03-30 Thread Anthony
The "formargs" argument applies to the view, create, and update forms 
generated by the grid, not the search widget. But as long as you're 
creating a custom search form, why not just directly set keepvalues in the 
searchform() code?

Anthony

On Friday, March 30, 2018 at 4:05:32 PM UTC-4, Shrabya Timsina wrote:
>
> Thanks for clarifying Anthony, but I did try formargs in the ways you 
> suggested and did not get any values kept in the form after submission. 
> Here is my grid definition. I am using my own search_widget. Could that be 
> part of the problem?
>
>
> def searchform(fields, url):
>
> family = Field("family", "string", required=False)
> genus = Field("genus", "string", required=False)
> species = Field("species_epithet", "string", required=False)
> collector_number = Field("collector_number", "string", required=False)
> form = SQLFORM.factory(
> family, genus, species, collector_number,
> _method='get', _action="#specimen_counter",
> buttons = [TAG.button('Search',_type="submit", _class="btn 
> btn-success mr-4"),
> TAG.button('Clear',_type="reset", _class="btn btn-default 
> btn-primary")])
> return form
>
> grid = SQLFORM.grid(query=result_set, formargs={'keepvalues': True}, 
> fields=fields, headers=headers,
> create=False, deletable=False, editable=False, links=links, 
> csv=False,
> details=False, search_widget=searchform)
>
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to keepvalues in SQLform.grid search form after submission

2018-03-30 Thread Shrabya Timsina
Thanks for clarifying Anthony, but I did try formargs in the ways you 
suggested and did not get any values kept in the form after submission. 
Here is my grid definition. I am using my own search_widget. Could that be 
part of the problem?


def searchform(fields, url):

family = Field("family", "string", required=False)
genus = Field("genus", "string", required=False)
species = Field("species_epithet", "string", required=False)
collector_number = Field("collector_number", "string", required=False)
form = SQLFORM.factory(
family, genus, species, collector_number,
_method='get', _action="#specimen_counter",
buttons = [TAG.button('Search',_type="submit", _class="btn 
btn-success mr-4"),
TAG.button('Clear',_type="reset", _class="btn btn-default 
btn-primary")])
return form

grid = SQLFORM.grid(query=result_set, formargs={'keepvalues': True}, fields=
fields, headers=headers,
create=False, deletable=False, editable=False, links=links, csv=
False,
details=False, search_widget=searchform)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to keepvalues in SQLform.grid search form after submission

2018-03-26 Thread Anthony
On Monday, March 26, 2018 at 4:26:52 PM UTC-4, Shrabya Timsina wrote:
>
> Thank you Anthony. Yes, I did experiment with that argument, but there is 
> no example of how to use it online.
>

It's just a dictionary of arguments you would normally pass to SQLFORM.

 I tried the following:
> formargs=dict("keepvalues"=True)


When using dict(), the keys doe not go in quotes:

formargs=dict(keepvalues=True)

or:

formargs={'keepvalues': True}

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to keepvalues in SQLform.grid search form after submission

2018-03-26 Thread Shrabya Timsina
Thank you Anthony. Yes, I did experiment with that argument, but there is 
no example of how to use it online. I tried the following:
formargs=dict("keepvalues"=True)

but that did not work. Could you let me know how to use this argument? This 
post  asks for 
an example of formargs but never gets a proper response.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: how to keepvalues in SQLform.grid search form after submission

2018-03-20 Thread Anthony
.grid() takes a "formargs" argument, which is a dictionary of arguments to 
pass to the grid forms. There are also the more specific "createargs", 
"editargs", and "viewargs" arguments, for create, edit, and view forms, 
respectively.

Anthony

On Tuesday, March 20, 2018 at 2:09:09 PM UTC-4, Shrabya Timsina wrote:
>
> Hello, I really like the keepvalues option for the form/sqlform objects 
> where you can pass it to their process/accepts method. 
> I understand the grid object also has an underlying sqlform, but I do not 
> understand how to access that in order to use its keepvalues=True option. 
> Based on my search, it seems like I have to use the onupdate parameter of 
> grid but I do not understand how to use it. Please help.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.