I then tried with XML output.
It works......
Just I needed to format the string output like str(mystring) while
forming the XML.

But it takes very long time for loading large data (e.g. more than
5000 rows).

How do I fetch the data from server, in step-by-step manner (i.e.
fetch first 'n' records when the user clicks on next button,  and so
on) ?



On Jun 13, 12:40 pm, Vineet <[email protected]> wrote:
> oops...
> while parsing the string in controller, there was a bug.
> Now I can escape the u character by using .encode('utf-8')
>
> But still there are 2 questions---
>
> 1) using .encode('utf-8') everywhere is not preferable for me.
> Is there any alternative, by which the default string encoding can be
> set to utf-8?
>
> 2) After returning the dict to jqGrid in View (cited in my original
> post),
> the grid is not rendered.
> Am I doing anything wrong in it?
>
> Thanks,
> Vineet
>
> On Jun 12, 9:56 pm, Vineet <[email protected]> wrote:
>
>
>
> > Hi !
> > (re-posting this, since my earlier post was unsuccessful).
> > Database back-end is MySQL
> > =========
> > Controller:--
> > =========
> > def do_something():
> >   result = db.executesql('select acnm,acgrp,accd from ac',
> > as_dict=True)
> >   return dict(result=result)
>
> > =====
> > View:--
> > =====
> > do_something.html
>
> > {{extend 'layout.html'}}
> > <table id="custlist"></table>
> > <script>
> > jQuery("#custlist").jqGrid({
> >     datatype: "local",
> >     height: 250,
> >     colNames:['Name','Group', 'Code'],
> >     colModel:[{name:'acnm',index:'acnm', width:150, sortable:true},
> >                    {name:'acgrp',index:'acnm', width:150,
> > sortable:true},
> >                    {name:'accd',index:'acnm', width:150,
> > sortable:true}
> >     ],
> >     multiselect: true,
> >     caption: "Customer Data"});
>
> > var mydata = {{=XML(result)}};
> > for(var i=0;i<=mydata.length;i++)
> >     jQuery("#custlist").jqGrid('addRowData',i+1,mydata[i]);
> > </script>
>
> > ============================
>
> > But the result is a blank page.
>
> > I checked the source of browser page to find that result contained an
> > array like this:--
> > [{'acnm': u'Vineet', 'accd': u'200124', 'acgrp': u'home'},......]
>
> > Pl. note the u character (for unicode?) before each value in the
> > dictionary.
>
> > Then I tried to do like following:--
> > 1) In controller, parse the dictionary values
> > 2) check if it is string
> > 3) If string, then .encode('utf-8') the values.
> > 4) return the modified dict
>
> > But still no success in rendering the view.
>
> > Then I tested the jqGrid code by giving a hardcoded "result" array
> > directly into <script> tag.
> > It works.....
> > I tested with returning result=db().select(db.acid>0)
> > It works.....
>
> > So, my question is : How to get rid of the u character while returning
> > result from executesql('select....)?
> > I need this executesql for giving very complex queries.
>
> > Can anybody pl. help?
>
> > Thanks,
>
> > Vineet- Hide quoted text -
>
> - Show quoted text -

Reply via email to