Hi Mike,
I would like to thank you for the example source code. The first
web2py & jqGrid integration source code. This a great help for those
who are interested in this JQuery plugin.
Regards,
Ed

On Mar 25, 9:46 pm, Mike <michael.mcgreg...@gmail.com> wrote:
> Hi Ed...
>
> I'm no expert but here's what I'm doing for the URL,
>
> url: '../controller/function1'
>
> Here's a more complete example...I know there a several places where
> more web2py-esqe helpers or style would help but this is how I first
> mocked up jqGrid.
>
> myview.html
> ==========
>
> {{extend 'layout.html'}}
> {{include 'jqgrid_refs.html'}} <!--this has the references for the
> jqGrid files-->
>
> <!--This is the jqgrid definition.-->
> <script type="text/javascript">
> jQuery(document).ready(function(){
>   jQuery("#grid").jqGrid({ <!--this is the id used to position the
> grid in the html below-->
>     imgpath: '/{{=request.application}}/static/themes/coffee/images',
> <!-- sets the theme used for the grid-->
>     caption: 'My Grid', <!-- text to display in the header-->
>     url: '../controller/function1', <!-- this is an asyncronous call
> to get the data for the grid-->
>     datatype: 'xml', <!--the grid expects xml formatted data (see
> jqGrid docs for the default xml document structure)-->
>     mtype: 'GET',
>     height: '100%',
>    colNames: ['col1','col2', 'col3'],
>     colModel :[
>       {name:'col1', index:'col1', width:55, sorttype:'text},
>       {name:'col1', index:'col1', width:55, sorttype:'text},
>       {name:'col1', index:'col1', width:55, sorttype:'text}
>       ],
>     sortname: 'col1', <!--default sort column-->
>     sortorder: 'asc', <!--default sort direction-->
>     pager: jQuery('#pager'), <!--this is the id used to position the
> pager controls in the html view-->
>     rowNum:20, <!--default number of rows to display-->
>     rowList:[20,40,60,80,100], <!--dropdown choices to select the
> number of rows to display-->
>     viewrecords: true, <!--displays the total number of rows in the
> entire set in the pager bar-->
>
>     });
>
> </script>
>
> <!--page headings-->
> <h2>This is your jqGrid...</h2>
>
> <!--add the grid and pager-->
> <table id="grid" class="scroll"></table>
> <div id="pager" class="scroll" style="text-align:center;"></div>
>
> jqgrid_refs.html
> ============
> <link rel="stylesheet" type="text/css" media="screen" href="/
> {{=request.application}}/static/themes/coffee/grid.css" />
> <link rel="stylesheet" type="text/css" media="screen" href="/
> {{=request.application}}/static/themes/jqModal.css" />
> <script src="/{{=request.application}}/static/jquery.js" type="text/
> javascript"></script>
> <script src="/{{=request.application}}/static/jquery.jqGrid.js"
> type="text/javascript"></script>
> <script src="/{{=request.application}}/static/js/jqModal.js"
> type="text/javascript"></script>
> <script src="/{{=request.application}}/static/js/jqDnR.js" type="text/
> javascript"></script>
>
> Controller
> ========
> def myview():
>     return dict()
>
> def function1():
>     response.headers["Content-Type"]="text/xml"
>     #start the XML data set
>     mystr = "<?xml version='1.0' encoding='utf-8'?><rows><page>1</
> page><total>1</total><records>10</records>"
>
>     #get the data from the database
>     records = db.executesql("SELECT TOP 10 col1, col2, col3 FROM
> tbl1") #MS SQL Server
>
>     #build XML from dataset
>     for row in records:
>         mystr = mystr + "<row id ='" +str(row.col1) + "'>"
>         mystr = mystr + '<cell>' + str(row.col1) + '</cell>'
>         mystr = mystr + '<cell>' + str(row.col2) + '</cell>'
>         mystr = mystr + '<cell>' + str(row.col3) + '</cell>'
>         mystr = mystr + '</row>'
>     mystr = mystr +'</rows>'
>
>     return mystr
>
> Hope that helps.
>
> Mike
>
> On Mar 24, 9:41 pm, ed <edbi...@rocketmail.com> wrote:
>
> > Hi Mike,
> > I am a web2py newbie and has to learn much from experts like you.
> > I would like to know which of the following url format you are using
> > to access your xml data in your server:
>
> > 1.  url: "{{=URL(r=request,c='default',f='getjsdata')}}",
> > 2.  url: '/EMIS/controllers/getjsdata.py',
>
> > Is it 1 or 2? Is it possible if you can email a source code of an
> > application
> > using web2py and jqGrid, I understand you are using jqGrid. I am also
> > very
> > interested to use jqGrid in web2py but not much documentation. I think
> > you
> > can provide the much needed example on this for everyone interested
> > in
> > this technology. Thanks in advance.
> > Ed
>
> > On 24 Mar, 01:36, Mike <michael.mcgreg...@gmail.com> wrote:
>
> > > Hey Ed,
>
> > > We're using jqGrid with XML data. Something thoughts (if you haven't
> > > tried them already):
>
> > > 1.) Try your grid with the FireBug plugin for FireFox and look at the
> > > response being returned to the grid. I've had web2py tickets thown at
> > > that point and the only to see it is via Firebug. Or just check for
> > > tickets from the admin app
>
> > > 2.) Did you set the response headers? in my case I had to
> > > use...response.headers["Content-Type"]="text/xml"
>
> > > 3.) What does your controller look like? In my controller that serves
> > > up the XML I just return a string with the XML data "return xml"
> > > instead of "return dict(xml = xml)"
>
> > > Hope that helps. I like jqGrid since it has excellent documentation
> > > and hope more of us can make it work with web2py.
>
> > > Mike
>
> > > On Mar 23, 5:27 am, ed <edbi...@rocketmail.com> wrote:
>
> > > > Hi,
> > > > I've been trying to execute a jquery jqGrid url to return JSON data
> > > > but failed. Only a blank table with exact headings is displayed. I
> > > > tried changing the url several times but no data is displayed. The
> > > > following is part of the code.
> > > > ---------------------------------------------------------------------------­­---------------------------
>
> > > > <script src="{{=URL(r=request,c='static',f='jqGrid34/jquery.js')}}"
> > > > type="text/javascript"></script>
> > > > <!-- and at end the jqGrid Java Script file -->
> > > > <script src="{{=URL(r=request,c='static',f='jqGrid34/
> > > > jquery.jqGrid.js')}}" type="text/javascript"></script>
> > > > <script type="text/javascript">
> > > >   jQuery(document).ready(function(){
> > > >     jQuery('#list2').jqGrid({
> > > >     //
> > > >     // this is the url I am using but failed to display data
>
> > > >     url: "{{=URL(r=request,c='default',f='getjsdata')}}",
>
> > > >     // I created a program in controllers to return json data and
> > > > tried the url below to access the program but also failed to display
> > > > data
> > > >     url: '/EMIS/controllers/getjsdata.py',
> > > >     //
> > > >     datatype: 'json',
> > > >     colNames:['Emp. No.','Last Name', 'First Name', 'Mid Name', 'Cost
> > > > Center', 'SSS No.'],
> > > >     colModel:[
> > > >         {name:'empno',index:'empno', width:80},
> > > >         {name:'lname',index:'lname', width:160},
> > > > ------------------------------------------------------------------------
> > > > Maybe the url address format is wrong or whatever. Can someone help me
> > > > on this.
> > > > Thank you very much.
> > > > Ed- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to