Hi Alan,
Thanks for the response, you are correct. I was passing what I thought was
a query to the SQLForm.grid function without realizing that when you call
.select() on a query it then becomes a Rows object.
I've realize because of the Left join query I use, I'm not going to be able
to use the SQLForm.grid. So, I've realigned my thinking. I'm also
attempting to render the data as an Ext.js item, so I'm working more in the
following line of thought:
def compliance():
rows=
db((db.MONITOR_CODES.MC_ID==db.MC_VALID_RESPONSES.MC_ID)&(db.MC_VALID_RESPONSES.COMPLIANCE_FLAG=='N')).select(db.MONITOR_CODES.MC_DESCR,
db.MC_VALID_RESPONSES.MC_ID.count(),left=db.MONITOR_CODES.on
(db.MONITOR_CODES.MC_ID==db.MC_VALID_RESPONSES.MC_ID),groupby=db.MONITOR_CODES.MC_ID).as_list()
pagescript = str(SCRIPT('''
Ext.onReady(function(){
var t= '''+ str(gluon.contrib.simplejson.dumps(rows))+''';
var main = Ext.create('Ext.Viewport', {
layout: {
xtype: 'vbox',
align: 'stretch',
pack:'center',
},
title: 'Non-Compliance Monitor Codes',
items: [{
items: [tb],
height: tb.height,
minHeight: tb.height,
},{
items:'''+str(rows)+''',
height: 200,
minHeight: 200
}],
renderTo: "main"
});
});
''', _language='javascript'))
return dict(pagescript=XML(pagescript))
Of course this just dumps the JSON data into the javascript in the very
ugly JSON array I should be expecting from that call. Which is just fine.
Now I just have to figure out how to render that JSON data in a nice table
with Column headers. The JSON data comes out like this in the item brackets
when you look at "view source":
items:[{'MONITOR_CODES': {'MC_DESCR': '"Are you using a bednet correctly every
night?"'}, '_extra': {'COUNT(MC_VALID_RESPONSES.MC_ID)': 1}}, {'MONITOR_CODES':
{'MC_DESCR': '"Do you have a military or civilian bednet issued to you?"'},
'_extra': {'COUNT(MC_VALID_RESPONSES.MC_ID)': 1}}, {'MONITOR_CODES':
{'MC_DESCR': '"If you have a civilian bednet, is it treated with
insecticide?"'}, '_extra': {'COUNT(MC_VALID_RESPONSES.MC_ID)': 1}},
{'MONITOR_CODES': {'MC_DESCR': '"If you have a civilian bednet, are you tucking
it under the mattress every night when you use it?"'}, '_extra':
{'COUNT(MC_VALID_RESPONSES.MC_ID)': 1}}, {'MONITOR_CODES': {'MC_DESCR': '"Is
your bednet in good shape with no holes in the netting?"'}, '_extra':
{'COUNT(MC_VALID_RESPONSES.MC_ID)': 1}}, {'MONITOR_CODES': {'MC_DESCR': 'Why
Not?'}, '_extra': {'COUNT(MC_VALID_RESPONSES.MC_ID)': 2}}, {'MONITOR_CODES':
{'MC_DESCR': 'Why Not?'}, '_extra': {'COUNT(MC_VALID_RESPONSES.MC_ID)': 3}},
{'MONITOR_CODES': {'MC_DESCR': 'Why Not?'}, '_extra':
{'COUNT(MC_VALID_RESPONSES.MC_ID)': 2}}],
Cheers,
Jamie
On Saturday, March 9, 2013 6:13:24 PM UTC-5, Jamie Jernigan wrote:
>
> Hi ,
>
> I'm new to Web2py and I've been struggling with this the last couple of
> days. I'm getting
> 'Rows' object has no attribute '_db'
>
>
> on:
>
> query=
> db((db.MONITOR_CODES.MC_ID==db.MC_VALID_RESPONSES.MC_ID)&(db.MC_VALID_RESPONSES.COMPLIANCE_FLAG=='N')).select(db.MONITOR_CODES.MC_DESCR,
>
> db.MC_VALID_RESPONSES.MC_ID.count(),left=db.MONITOR_CODES.on
>
> (db.MONITOR_CODES.MC_ID==db.MC_VALID_RESPONSES.MC_ID),groupby=db.MONITOR_CODES.MC_ID)
>
> fields=[db.MONITOR_CODES.MC_DESCR, db.MC_VALID_RESPONSES.MC_ID.count()]
> headers={db.MONITOR_CODES.MC_DESCR: 'Non-Compliant Codes',
> db.MC_VALID_RESPONSES.MC_ID.count(): 'Number of Non-Compliant
> Responses'}
>
> form = SQLFORM.grid(query=query, fields=fields, headers=headers,
> sortable=True, create=False, deletable=False, editable=False,
> maxtextlength=64, paginate=25)
>
> Thank you for your time,
>
> Jamie
>
--
---
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/groups/opt_out.