Substitute a javascript call for an AJAX request in the AjaxSQL buffer : Ajax « Rico « JavaScript DHTML

Home
JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
4.Development
5.Document
6.Dojo toolkit
7.Event
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
12.HTML
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
16.jQuery
17.Language Basics
18.Mochkit
19.Mootools
20.Node Operation
21.Object Oriented
22.Page Components
23.Rico
24.Scriptaculous
25.Security
26.SmartClient
27.Style Layout
28.Table
29.Utilities
30.Window Browser
31.YUI Library
JavaScript DHTML » Rico » Ajax 




Substitute a javascript call for an AJAX request in the AjaxSQL buffer
 
<!--
Apache License, Version 2.0

Revised from Rico 2.0  demo code.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Rico LiveGrid-JavaScript Buffer</title>

<script src="rico21/src/rico.js" type="text/javascript"></script>
<link href="rico21/examples/client/css/demo.css" type="text/css" rel="stylesheet" />
<script type='text/javascript'>
Rico.loadModule('LiveGridAjax','LiveGridMenu','greenHdg.css');

var grid, buffer;

Rico.onLoadfunction() {
  var opts = {  
    frozenColumns : 1,
    useUnformattedColWidth: false,
    columnSpecs  : [{width:200}]
  };
  buffer=new Rico.Buffer.AjaxSQL(jsfetch);
  grid=new Rico.LiveGrid ('jsgrid', buffer, opts);
  grid.menu=new Rico.GridMenu();
});

function jsfetch(options) {
  Rico.writeDebugMsg("jsfetch");
  var newRows=[], totrows=500;
  var offset=options.parameters.offset;
  var limit=Math.min(totrows-offset,options.parameters.page_size)
  for (var r=0; r<limit; r++) {
    var row=[];
    row.push(new Date().toString());
    row.push(offset.toString());
    for (var c=2; c<5; c++)
      row.push('cell '+(r+offset)+':'+c);
    newRows.push(row);
  }
  options.onComplete(newRows,false,totrows);
}
</script>

<style type="text/css">
div.ricoLG_cell white-space: nowrap; }
</style>
</head>

<body>
<div id='explanation'>
This example demonstrates how to substitute a javascript
call for an AJAX request in the AjaxSQL buffer. Rather than
passing a string containing the url to the data provider,
you pass a function to the Rico.Buffer.AjaxSQL constructor.
<pre>
buffer=new Rico.Buffer.AjaxSQL(<strong>jsfetch</strong>);
function <strong>jsfetch</strong>(options) {
  var newRows=[], totrows=500;
  var offset=options.parameters.offset;
  var limit=Math.min(totrows-offset,options.parameters.page_size)
  for (var r=0; r&lt;limit; r++) {
    var row=[];
    row.push(new Date().toString());
    row.push(offset.toString());
    for (var c=2; c&lt;5; c++row.push('cell '+(r+offset)+':'+c);
    newRows.push(row);
  }
  options.onComplete(newRows,false,totrows);
}
</pre>
</div>

<p class="ricoBookmark"><span id="jsgrid_bookmark">&nbsp;</span></p>
<table id="jsgrid" class="ricoLiveGrid" cellspacing="0" cellpadding="0">
  <tr>
    <th>Time of Data Fetch</th>
    <th>Offset</th>
    <th>Column 3</th>
    <th>Column 4</th>
    <th>Column 5</th>
  </tr>
</table>

<!--
<textarea id='jsgrid_debugmsgs' rows='5' cols='100' style='font-size:x-small;'></textarea>
-->
</body>
</html>

   
  














Related examples in the same category
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.