|
- define(function(require){
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
- var ShellImpl = require("$UI/system/lib/portal/shellImpl");
- var PadDB = require("$UI/padDemo/padDB");
- var SqliteUtil = require("$UI/padDemo/sqliteUtil");
- var Data = require("$UI/system/components/justep/data/data");
- require("$UI/system/lib/cordova/cordova");
- require("cordova!org.apache.cordova.network-information");
-
-
- var Model = function(){
- this.callParent();
- };
-
- Model.prototype.modelLoad = function(event){
- var self = this;
- document.addEventListener("deviceready", function() {
- // 获取数据库单例对象
- self.padDB = PadDB.getInstance();
- // 初始化数据库
- self.padDB.initData(function() {
- // 初始化成功后刷新tree
- self.comp("revealData").refresh();
- });
- });
- };
-
- Model.prototype.revealDataCustomRefresh = function(event){
- event.async = true;
- <font color="Red">var db = this.padDB.getDatabase(); 这句Cannot read property 'getDatabase' of undefined</font>
- var revealData = this.comp("revealData");
- $.ajax({
- async:"false",
- type:"post",
- url:"/pis/mobile/share/getHintList",
- dataType : "json",
- data:{TYPE:1},
- success : function(result) {
- revealData.loadData(result);
- //使用data组件的each方法把所有的行状态都改为编辑过的状态
- revealData.each(function(param){
- revealData.setRowState(param.row,Data.STATE.EDIT);
- });
-
- SqliteUtil.saveData(db, result, "tb_file", null, function(res) {
- // 异步执行模式下,保存成功后必须执行doSaveAfter
- data.doSaveAfter(true, event.options);
- }, function(msg) {
- data.doSaveAfter(false, event.options);
- });
- }
- });
- };
-
- return Model;
- });
复制代码 sqliteUtil padDB.js 都是案例复制过来的 padDB.sql也是仿写案例的。
|
|