[web2py] Re: csv download problem from an SQLFORM.grid populated by an AJAX call

2015-04-25 Thread drmbded


 While putting together an example of the error I found that my example 
 worked fine, in fact I'm getting HTML instead of CSV from a grid that was 
 not created from an AJAX call.


This must be something that I've cause but with such a simplified 
application I'm stumped as to what is causing this. 

Looking through the HTML I can see my error printed out from the traceback 
and here's what it shows:

got an error: (200 OK) Traceback (most recent call last):
   File 
quote;/opt/web2py/applications/testApp/controllers/audit.pyquote;, line 
32, in auditUsers
   grid=SQLFORM.grid(dbOra.personnel)
   File quote;/opt/web2py/gluon/sqlhtml.pyquote;, line2225, in grid
  raise HTTP(200, oExxp.export(), **response.headers)
HTTP: 200 OK

 

My controller is very simple:

def auditUsers():
   try:
  grid=SQLFORM.grid(dbOra.personnel)
   except Exception, err:
  grid='got an error: (%s) %s' %(str(err), traceback.format_exc())
   return(message=done,grid=grid)

And my view is just as simple:

{{right_sidebar_enabled,left_sidebar_enabled,('message' in globals())}}
{{extend 'layout.html'}}

h1{{=message}}/h1
{{=grid}}


-- 
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] csv download problem from an SQLFORM.grid populated by an AJAX call

2015-04-20 Thread drmbded
I regularly use the SQLFORM.grid, does exactly what I need with very little 
effort. Recently I've been doing a lot more with AJAX to enhance how my 
pages look and feel. But when combining AJAX with the grid, my CSV 
downloads don't work as expected.

In a simple page with only a combobox an empty DIV and small amount of 
javascript (actually using Nathan Freeze's client tools, excellent bit of 
kit!), selecting an item from the combobox causes an AJAX call back to 
web2py. The AJAX call returns an SQLFORM.grid, looks good!

But when I click the CSV download button Excel opens up with a bunch of 
HTML instead of the CSV contents of the grid. In fact it looks like the 
HTML doesn't include any of the grid's contents.

I believe that the CSV URL that gets created by the SQLFORM.grid is 
presuming that the grid itself is included in the original URL download so 
that the grid will see the CSV download request. Since the grid is download 
through AJAX the CSV URL is incorrect and I just get the original HTML with 
the combobox and empty DIV.

Is there a way to tell the grid what the actual URL should be for the CSV?

Thanks,
-Michael


-- 
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] sqlform.grid populated with an AJAX call, grid search doesn't work correctly

2015-03-04 Thread drmbded
I have a relatively simple page which has a drop down selection and an 
empty DIV. When a user selects an item from the drop down an ajax call back 
to web2py creates an sqlform.grid with a left join query and populates the 
empty DIV with the grid. This works great.

Now if I use the search capability of the grid: after filling in the search 
criteria and clicking on the Search button, the submit sends me to a page 
which just says Nothing to show.

I suspect that the grid isn't quite configured correctly to cause the 
Search/Submit to populate the DIV with the results. Or is the issue that 
the grid was created with a left join it can't reconcile the left join with 
the search criteria?

-- 
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.


Re: [web2py] how to set a default represent for all fields

2014-10-14 Thread drmbded
 I was expecting an elegant web2py solution but brute force works too. 
Thanks Richard.

-- 
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] how to set a default represent for all fields

2014-10-13 Thread drmbded
I've gotten several complaints from my users about fields that display 
the value None. In some cases the actual field value could be None verses 
the database field just being empty (and displaying the value None).

I've started using represent when I describe my tables so that an empty 
field displays '---':
   Field('aField',represent = lambda value,row: '---' if value == None else 
value)

Is there a way to have web2py default  to display '---' for an empty 
database field? This would be much easier that updating my table 
descriptions.

Thanks

-- 
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.