Thanks a lot now I've got it, have a nice day.

Il giorno lunedì 14 ottobre 2013 14:07:32 UTC+2, Niphlod ha scritto:
>
> I think you don't have a clear "bigger picture" of all the pieces involved.
> In order to update a component, you need to have it loaded somewhere you 
> know inside the page.
> This mean that there will be a certain div with id "iwillreload" inside 
> your page that will point to the page that generates the grid.
> In order to replace that component with a click on a link "outside" that 
> "iwillreload" component, you NEED to tell to the link where you want that 
> link to be loaded.
>
> so, first of all, in your "main" page, you need to include a 
>
> LOAD(c='default', f='thegrid.load', ajax=True, target='iwillreload')
>
> This will create a div with id iwillreload inside your page, with 
> default/thegrid.load called via ajax to fill this page "fragment".
>
> To replace that component clicking on a link, with that link being the 
> source of the wanted "new fragment", you need to do
>
> A('click this', callback=URL('default', 'thegrid.load', 
> vars=dict(something=else), user_signature=True), target="iwillreload")
>
> i.e. you need to tell to A where would you want that url loaded.
>
> Il giorno lunedì 14 ottobre 2013 12:02:28 UTC+2, Gael Princivalle ha 
> scritto:
>>
>> Hi Niphlod.
>>
>> Now I use request.vars instead of request.args and it works, I don't have 
>> anymore the flash "Not authorized" message.
>> Here is the hp.load file:
>>     {{=grid}}
>>     {{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}
>>
>> When I load only the hp.load file it works, but when I load it inside the 
>> html file no, hp.load file reload without a query update (I have all rows).
>>
>> Do you know why ?
>>
>> .html file:
>>     {{=grid}}
>>     {{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}
>>
>> Controller hp.py:
>> def hp():
>>     db.models.pdf_path.readable = False
>>     if request.vars['cat']:
>>         cat_to_show=str(request.vars['cat'])
>>         query = db.models.category==str(cat_to_show)
>>         response.flash = 'Category to show is ' + cat_to_show
>>     else:
>>         query = db.models
>>         response.flash = 'Request.vars[cat] is empty, show all rows'
>>     fields = 
>> (db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
>>     headers = {'models.code':   T('Product model'),
>>            'models.category': T('Category'),
>>            'models.description_it': T('Description'),
>>            'models.pdf_path': 'pdf_path' }
>>     links = [dict(header=T('Catalogue'), body=lambda row: A('Download', 
>> _href=row.pdf_path, _target='_blank'))]
>>     maxtextlengths={'models.code': 6, 'models.description_it': 120}
>>     grid = SQLFORM.grid(query, headers=headers, fields=fields, csv=False, 
>> maxtextlengths=maxtextlengths, orderby=db.models.code, 
>> links=links,links_in_grid=True)
>>     return dict(grid=grid)
>>
>> Il giorno domenica 13 ottobre 2013 20:33:22 UTC+2, Niphlod ha scritto:
>>>
>>> grid uses signed links by default (otherwise, you could access all data 
>>> just changing the url). Make sure that all links fiddling with grid "own" 
>>> links (such as lining directyl to the edit action of some record) are 
>>> signed. 
>>> Also, grid uses request.args to detect what you're trying to do, so if 
>>> you want to use something like /app/default/index/whatever as a "base url", 
>>> you should pass also args=request.args[:1] to tell the grid that it should 
>>> only consider what comes after the "whatever".
>>>
>>>
>>> On Sunday, October 13, 2013 8:24:15 PM UTC+2, Gael Princivalle wrote:
>>>>
>>>> Tim, Niphlod thank you for your answers. @Niphlod "Luke" means that's 
>>>> I'm a skywalker ? I would like to ! 
>>>> Components are pretty useful, I've tried the documentation tutorial, 
>>>> that's ok.
>>>> I'm still having some problems on this topic.
>>>> 1/My left side bar is under the grid
>>>> 2/I don't reach to give some args to the grid. As args I've just got to 
>>>> give a category number. I've made a test link with "1". If I load only the 
>>>> .load file clicking on the link it show al rows. With the .load file 
>>>> inside 
>>>> the .html file, it returns me this message "not authorized".
>>>>
>>>> Here is my hp.load file in a dedicated component folder called hp:
>>>> {{left_sidebar_enabled=True,}}
>>>> {{=grid}}
>>>> <!-- Here I've made a test link for showing rows that have 1 for 
>>>> category. In the future all the vertical side menu will have similar links 
>>>> --> 
>>>> {{=A('Test',callback=URL('hp.load', args='1'))}}
>>>> {{block left_sidebar}}
>>>> <!--...My left side menu -->
>>>>
>>>> My dedicated controller hp.py:
>>>> def hp():
>>>>     #I don't want to show this field. I'm gone take care of it under 
>>>> with the lambda function
>>>>     db.models.pdf_path.readable = False 
>>>>     if request.args(0): #If there's an arg, it means that I have to 
>>>> make a query with this category number
>>>>         query = db.models.category==request.args(0)
>>>>     else: #Else, I have to show all rows
>>>>         query = db.models
>>>>     fields = 
>>>> (db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
>>>>     #I set my headers
>>>>     headers = {'models.code':   T('Product model'),
>>>>            'models.category': T('Category'),
>>>>            'models.description_it': T('Description'),
>>>>            'models.pdf_path': 'pdf_path' }
>>>>     #Here I take care about pdf_path for having a link on it.
>>>>     links = [dict(header=T('Catalogue'), body=lambda row: A('Download', 
>>>> _href=row.pdf_path, _target='_blank'))]
>>>>     maxtextlengths={'models.code': 6, 'models.description_it': 120}
>>>>     #Here is my construction grid
>>>>     grid = SQLFORM.grid(query, headers=headers, fields=fields, 
>>>> csv=False, maxtextlengths=maxtextlengths, orderby=db.models.code, 
>>>> links=links,links_in_grid=True)
>>>>     return dict(grid=grid)
>>>>
>>>> My h_products.html view:
>>>> {{extend 'layout.html'}}
>>>> {{=LOAD('hp','hp.load',ajax=True)}}
>>>>
>>>> How can I resolve these problems ?
>>>>
>>>> Il giorno giovedì 10 ottobre 2013 20:45:45 UTC+2, Tim Richardson ha 
>>>> scritto:
>>>>>
>>>>> A web2py component will make the grid controlled by ajax, which means 
>>>>> you can reload it from your page with javascript when some event happens, 
>>>>> and that reloading is done the ajax way, without reloading the entire 
>>>>> page. 
>>>>> And there's more. Read about components in the book.
>>>>
>>>>

-- 
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/groups/opt_out.

Reply via email to