Do you get any errors in the console? That's the first place I usually
look...
On Sunday, March 24, 2013 8:42:45 PM UTC-4, Nate wrote:
>
> Hi
>
> I have a controller sending JSON to my view. I cannot get the data into
> the TreeGrid. The Json is coming down correctly (I placed it manually and
> it works). Running this code places the JSON on the webpage. Controller and
> View below.
>
> Help appreciated.
> Regards
> Nate
>
> CONTROLLER
> @service.json
> def get_report():
> import json
>
> rows = db(db.neighbourhood.id > 0).select().as_list()
> concat = '{"response":['
> seq =1
> for row in rows:
> row['id'] = seq
> concat = concat + json.dumps(row)+","
> seq = seq+1
> innerrows = db(db.report.parent ==
> row.get('id')).select().as_list()
> for innerrow in innerrows:
> innerrow['id'] = seq
> concat = concat + json.dumps(innerrow) + ","
> seq = seq+1
> concat = concat.strip( ',' )
> concat = concat + ']},grid;'
> return concat
>
>
> VIEW
> {{extend 'layout.html'}}
> <script type="text/javascript">
> jQuery(document).ready(function(){
> jQuery.getJSON("{{=URL(r=request,f='call',args=['json','get_report'])}}",
> function(msg){
> jQuery.each(msg, function(){
> topicjson = this;
>
> $('#treeGrid').jqGrid({
> datastr: topicjson,
> datatype: "json",
> height: "auto",
> mType: 'GET',
> treeGridModel: 'adjacency',
> colNames: [/*"id",*/"Items","url"],
> colModel: [
> {name: "elementName", width:250, resizable: false},
> {name: "url",width:1,hidden:true}
> ],
> treeGrid: true,
> caption: "Neighbourhood",
> ExpandColumn: "name",
> ExpandColClick:true,
> autowidth: true
> });
> })
> });
>
> });
> </script>
>
> <div style="width:180px;">
> <table id="treeGrid">
> </table>
>
--
---
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.