My fault. I extrapoled the code from more complex one.

Try this:

{{extend 'layout.html'}}
{{
w2p_grid_tbl = grid.element('table')
if w2p_grid_tbl:
 original_export_menu = grid.element('div.w2p_export_menu')
 export_menu_links = original_export_menu.elements('a')
 export_menu_items = []
 for link in export_menu_links:
     item = LI(link)
     export_menu_items.append(item)
 pass
 new_export_menu = DIV(
                      A( T('Exports'),
                         SPAN(_class='caret'),
                         _href='#',
                         _class='btn dropdown-toggle',
                         **{'_data-toggle':"dropdown"}
                        ),
                      UL(*export_menu_items,
                         _class='dropdown-menu'
                        ),
                    _class='w2p_export_menu btn-group'
                    )
 export_menu = grid.element('div.w2p_export_menu',replace=new_export_menu)
pass
}}

{{=grid}}

Of course you could modify the DOM directly in the controller.



Il giorno lunedì 22 ottobre 2012 22:56:48 UTC+2, Omi Chiba ha scritto:
>
> Wow! This is exactly what I wanted. I hope this will be the default layout 
> for grid.
>
> I copy and pasted your code between {{extend 'layout.html'}} and 
> {{=gird}}, then export labels are now disappeard...
> Maybe you should check your code with the latest (2.1.1). 
>
> {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in 
> globals())}}
> {{extend 'layout.html'}}
> {{
> w2p_grid_tbl = grid.element('table')
> if w2p_grid_tbl:
>  export_menu = grid.element('div.w2p_export_menu')
>  export_menu_links = export_menu.elements('a')
>  export_menu_items = []
>  for link in export_menu_links:
>      item = LI(link)
>      export_menu_items.append(item)
>  pass
>  export_menu = grid.element('div.w2p_export_menu',replace=None)
>  new_export_menu = DIV(
>                       A( T('Exports'),
>                          SPAN(_class='caret'),
>                          _href='#',
>                          _class='btn dropdown-toggle',
>                          **{'_data-toggle':"dropdown"}
>                         ),
>                       UL(*export_menu_items,
>                          _class='dropdown-menu'
>                         ),
>                     _class='w2p_export_menu btn-group'
>                     )
> pass
> }}
>
> {{=grid}}
>
>
>
>
> On Monday, October 22, 2012 2:10:53 PM UTC-5, Paolo Caruccio wrote:
>>
>> For grid export menu I'm happy with below method
>>
>> In the views/*.html file where is your grid put on top (just below extend 
>> layout command)  the following code:
>>
>> {{
>> w2p_grid_tbl = grid.element('table')
>> if w2p_grid_tbl:
>>  export_menu = grid.element('div.w2p_export_menu')
>>  export_menu_links = export_menu.elements('a')
>>  export_menu_items = []
>>  for link in export_menu_links:
>>      item = LI(link)
>>      export_menu_items.append(item)
>>  pass
>>  export_menu = grid.element('div.w2p_export_menu',replace=None)
>>  new_export_menu = DIV(
>>                       A( T('Exports'),
>>                          SPAN(_class='caret'),
>>                          _href='#',
>>                          _class='btn dropdown-toggle',
>>                          **{'_data-toggle':"dropdown"}
>>                         ),
>>                       UL(*export_menu_items,
>>                          _class='dropdown-menu'
>>                         ),
>>                     _class='w2p_export_menu btn-group'
>>                     )
>> pass
>> }}
>>
>> In the attached picture you can see how the exports menu is rendered 
>> using css bootstrap framework.
>>
>> The method is based on Server-side DOM and parsing (
>> http://web2py.com/books/default/chapter/29/05#Server-side-DOM-and-parsing) 
>> and it uses the elements argument "replace" (new beatiful and powerful - in 
>> my opinion - feature). For reference you could read 
>> https://groups.google.com/forum/?fromgroups=#!topic/web2py/fbYZXoIOkCY
>>
>> I hope this will help you.
>>
>>  
>>
>> Il giorno lunedì 22 ottobre 2012 17:15:37 UTC+2, Omi Chiba ha scritto:
>>>
>>> New export function on grid has many choices but I need to keep the old 
>>> format. (Export button for csv) because...
>>>
>>> - I'm using the gird for users (Maybe this format is good for us but not 
>>> users.)
>>> - Current export options layout is not pretty (I prefer button with 
>>> dropdown list)
>>> - I don't want users to see hidden columns
>>>
>>> Is there any option available for me?
>>>
>>>

-- 



Reply via email to