Could you indicate whether what you did work, please?
I've the same problem, when using appadmin/manage, which internally uses
the smartgrid:
opening a link in a new tab does not work (nor do the next / previous
buttons).
The problem I have when trying to implement Anthony's solution is the
following:
in some cases the grid component returns an image (when a field of the
table is an image) and this image is retrieved without ajax.
One dirty way to fix this consists in behaving differently depending on the
query to the smartgrid component, as it seems that these image queries are
of the form .../table/download/....
But is there a better solution?
Le vendredi 14 novembre 2014 17:30:01 UTC+1, Jim Karsten a écrit :
>
> I think I can make this work. Thanks for your help Anthony and Leonel.
>
> Jim
>
> On Thursday, November 13, 2014 9:33:04 AM UTC-5, Anthony wrote:
>>
>> A simpler option might be to check whether the request is being made via
>> Ajax, and conditionally change the view:
>>
>> def inner():
>> response.view = 'default/inner.load' if request.ajax else
>> 'default/inner.html'
>> grid = SQLFORM.grid(db.item)
>> return locals()
>>
>> In that case, the .html view should extend the layout. Alternatively, you
>> could have a single view with a conditional extends:
>>
>> {{extend 'layout.html' if not request.ajax else None}}
>>
>> Note that the view cannot be compiled in that case.
>>
>> Anthony
>>
>> On Thursday, November 13, 2014 7:37:49 AM UTC-5, Leonel Câmara wrote:
>>>
>>> The problem is that URL, when an extension is not specified, inherits it
>>> from the current URL which is .load in the case where they are loaded in
>>> components with extension='load'.
>>>
>>> The thing is, this need to be load, otherwise inner will use the generic
>>> HTML view extending layout.html and you don't want to have a layout inside
>>> your layout when you're not opening in a new window.
>>>
>>> So basically inner needs to detect whether it's really a component or
>>> not, generally that's what the extension is for. The only way I can
>>> remember to do this would be with stupid javascript hacks. For instance,
>>> you could make an inner.load view like this:
>>>
>>> {{=grid}}
>>>
>>>
>>> <script>
>>> $('.web2py_grid a').each(function() {
>>> if (typeof $(this).attr('href') !== 'undefined') {
>>> $(this).attr('href', $(this).attr('href').replace('.load',
>>> '.html'));
>>> $(this).click(function(e) {
>>> if (e.which == 1) { // If we're left clicking
>>> if(e.ctrlKey) { // ctrl key being pressed also means
>>> new tab
>>> window.open($(this).attr('href'));
>>> return false;
>>> } else { // We really want to stay in the component
>>> $(this).attr('href', $(this).attr('href').replace(
>>> '.html', '.load'));
>>> }
>>> }
>>> });
>>> }
>>> });
>>> </script>
>>>
>>>
>>> What this does is make all links have a .html extension, then if the
>>> user is left clicking it makes it .load again. Yep, it's ugly, but you
>>> asked for it.
>>>
>>> [edit] Added a return false that was needed.
>>>
>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.