PDA

View Full Version : Database record List View (sencha touch+phonegap)



KKS
28 Jan 2011, 7:57 PM
hi..

I want View Database records at List

Android + phonegap + sencha touch

Not error.... but Not viewing....

Help... :(
http://www.sencha.com/learn/Tutorial:A_Sencha_Touch_MVC_application_with_PhoneGap
This site was a reference....

Code : Contact.js


Ext.data.ProxyMgr.registerType("contactstorage",
Ext.extend(Ext.data.AjaxProxy, {
create: function(operation, callback, scope) {

},

read: function(operation, callback, scope) {
var thisProxy = this;
var contacts =[];
var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
db.transaction(function (tx){

tx.executeSql('SELECT * FROM Metadata', [], function (tx, results){
var len = results.rows.length, i;
for(i=0; i<len; i++){
var deviceContact = results.rows.item(i);
alert(deviceContact.title);
contact = deviceContact;
var contact = new thisProxy.model({
id : deviceContact.id,
title : deviceContact.title
});

contacts.push(contact);
}
})


});
operation.resultSet = new Ext.data.ResultSet({
records : contacts,
total : contacts.length,
loaded : false
});
operation.setSuccessful();
operation.setCompleted();

if(typeof callback == "function"){
callback.call(scope || thisProxy,operation);
}


},

update: function(operation, callback, scope) {


},

destroy: function(operation, callback, scope) {
},


})
);

app.models.Contact = Ext.regModel("app.models.Contact", {
fields: [
{name: "id", type: "int"},
{name: "title", type: "string"}
],
proxy: {
type: "contactstorage",
reader : {type : 'json'}
}
});

app.stores.contacts = new Ext.data.Store({
model: "app.models.Contact"
});




Code : Viewport.js


app.views.Viewport = Ext.extend(Ext.Panel, {
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide',
initComponent: function() {
//put instances of cards into app.views namespace
Ext.apply(app.views, {
contactsList: new app.views.ContactsList()
//contactDetail: new app.views.ContactDetail(),
//contactForm: new app.views.ContactForm()
});
//put instances of cards into viewport
Ext.apply(this, {
items: [
app.views.contactsList
//app.views.contactDetail,
//app.views.contactForm,
]
});
app.views.Viewport.superclass.initComponent.apply(this, arguments);
}
});




Code : ContactsList.js


app.views.ContactsList = Ext.extend(Ext.Panel, {
dockedItems: [{
xtype: 'toolbar',
title: 'Search'
}],
items: [{
xtype: 'list',
store: app.stores.contacts,
itemTpl: '{id} {title} ',
onItemDisclosure: function (record) {
//});
}
}
],
initComponent: function() {
app.stores.contacts.load();
app.views.ContactsList.superclass.initComponent.apply(this, arguments);
}
});

qcardona
16 May 2011, 11:17 PM
I'm having the same problem with phonegap 0.9.4 and Sencha Touch 1.1.

If I load phonegap.0.9.4.min.js in my index.html, my ListView disappears.
If I don't load phonegap.0.9.4.min.js, ListView works fine.

Any idea? Any incompatibility?

Thanks,
Quim