Hi,
If you can narrow down and specify your use case for synchronization,
maybe we can provide some suggestions.
Thanks,
Austin
On Oct 30, 11:38 pm, "Rohan's Book Library" <[EMAIL PROTECTED]>
wrote:
> Ext.onReady(function(){
> Ext.BLANK_IMAGE_URL = '../../ext-2.2/resources/images/default/s.gif';
> Ext.QuickTips.init();
> var db = google.gears.factory.create('beta.database');
>
> db.open('griddata');
> db.execute('create table if not exists geargd' +
> ' (id INTEGER PRIMARY KEY NOT NULL,Company
> text ,Price float(3),Change float(3),Pctchange float(4))');
>
> function handleSubmit(company,price,change,pctchange) {
> if (!google.gears.factory || !db) {
> return;
> }
> db.execute('insert into geargd (Company,Price,Change,Pctchange)
> values (?, ?, ?, ?)', [company,price,change,pctchange]);
>
> }
>
> function displayRecentPhrases() {
>
> var rs = db.execute('select id, Company, Price, Change, Pctchange
> from geargd order by id asc');
> var fs = [];
> while (rs.isValidRow()) {
> fs.push([rs.field(0), rs.field(1), rs.field(2), rs.field(3),
> rs.field(4)]);
> rs.next();
> }
> rs.close();
> return fs;
> }
>
> function delData(id) {
> db.execute('delete from geargd where id=?', [id]);
> }
>
> var ds = new Ext.data.SimpleStore({
> fields:[
> {name: 'id', type: 'int'},
> {name: 'company', type:'string'},
> {name: 'price', type: 'float'},
> {name: 'change', type: 'float'},
> {name: 'pctchange', type: 'float'}
> ]
> });
> ds.loadData(displayRecentPhrases());
>
> var form = new Ext.form.FormPanel({
> title:'Form',
> region:'north',
> frame:true,
> border:true,
> margins:{bottom:5},
> bodyStyle:'padding:10px;',
> height:110,
> defaults:{
> width:110,
> allowBlank:false
> },
> defaultType:'numberfield',
> items: [{
> xtype:'textfield',
> fieldLabel:'Company',
> name:'company'
> },{
> fieldLabel:'Price',
> name:'price'
> },{
> fieldLabel:'Change',
> name:'change'
> },{
> fieldLabel:'PctChange',
> name:'pctchange'
> }],
> buttons:[{
> text:'Add TO GRID',
> handler: function() {
> if (form.form.isValid()) {
> var v = form.form.getValues();
> handleSubmit(v.company, v.price, v.change,
> v.pctchange);
> ds.loadData(displayRecentPhrases());
> form.form.reset();
> }
> }
> }]
> });
>
> function displayFormWindow(){
> gridwin.show();
> }
>
> var grid = new Ext.grid.GridPanel({
> title: 'My First Grid',
> ds:ds,
> region:'center',
> frame:true,
> loadmask:true,
> tbar: [{
> text: 'Add a Value',
> tooltip:'Great Tooltip',
> iconCls:'add',
> handler: displayFormWindow
> }],
> columns: [
> {id:"id", header: "ID", width: 70, sortable: true, dataIndex:
> 'id'},
> {id:"company", header: 'Company', width: 120, sortable: true,
> dataIndex: 'company'},
> {header: 'Price', width: 90, sortable: true, dataIndex:
> 'price'},
> {header: 'Change', width: 90, sortable: true, dataIndex:
> 'change'},
> {header: '% Change', width: 90, sortable: true, dataIndex:
> 'pctchange'}
> ],
> stripeRows: true,
> viewConfig: {
> forceFit: true,
> enableRowBody:true,
> showPreview:true
>
> },
>
> width: 500,
> height:299,
> });
> grid.render('grid-example');
>
> // grid.getSelectionModel().selectFirstRow();
>
> //grid.on('rowdblclick', function (geargd,index) {
> /* grid.on('rowdblclick', function (gridgroup,
> rowIndex,columnIndex,event) {
> rowIndex = [rowIndex+(1)];
> alert(gridgroup+","+rowIndex+","+columnIndex+","+event);
> //rowIndex = [rowIndex+(1)];
> selected = grid.getSelectionModel().getSelected();
>
> // alert (selected.geargd.id);
> delData(selected.geargd.id);
> ds.loadData(displayRecentPhrases());
> }); */
>
> grid.on('rowdblclick', function (grid, rowIndex) {
> // rowIndex = [rowIndex+(1)];
> //alert(gridgroup+","+rowIndex+","+columnIndex+","+event);
> //rowIndex = [rowIndex+(1)];
> selected = grid.getSelectionModel().getSelected();
> alert(selected.geargd.id);
> delData(selected.geargd.id);
> ds.loadData(displayRecentPhrases());
> });
>
> var gridwin= new Ext.Window({
> id: 'win',
> title: 'Add to grid',
> closable:true,
> width: 300,
> height: 250,
> plain:true,
> layout: 'fit',
> items: form
> });
>
> /*var panel1 = new Ext.Panel({
> //style:'margin:1em;',
> renderTo:'grid-example',
> baseCls:'x-plain',
> width:600,
> height:400,
> border:false,
> frame:true,
> layout:'border',
> items:[
> form,
> grid
> ]
> })*/
>
> });
>
> i want data Syncronization in above example want to view the data feed
> by me from my local machine
> can be viewed by on other machine to in gears
>
> Can u please help me..
>
> please