如何使用 Kendo UI 查询本地 websql 数据库 [英] How to query a local websql DB with Kendo UI

查看:15
本文介绍了如何使用 Kendo UI 查询本地 websql 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这个问题对 SO 来说太宽泛了,请原谅我,但我正在努力寻找我需要的任何示例,并认为有人可能会为我指明正确的方向.

Forgive me if this question is too broad for SO but I'm struggling to find any examples of what I need and thought someone may be able to point me in the right direction.

我刚开始使用 Kendo UI 移动版,我正在尝试查找教程或任何示例代码,用于在 kendo ui 移动版中创建/查询本地客户端 websql 数据库.文档中没有任何内容...

I'm just starting out with Kendo UI mobile and am trying to find a tutorial or any example code for creating/querying a local client side websql database within kendo ui mobile. There is nothing in the docs...

有人可以帮忙吗?

提前致谢

推荐答案

您可以为 Kendo 数据源创建自定义传输.例如在 transport.read 中,您可以对您的 websql 数据库执行查询并返回结果:

You can create a custom transport for the Kendo DataSource. For example in transport.read you can perform a query to your websql database and return the result:

var dataSource = new kendo.data.DataSource({
   transport: {
      read: function(options) {

        db.transaction(function(tx) {

          tx.executeSql('SELECT * from my_table', [], function(tx, result) {

             var data = [];
             // copy the rows to a regular array
             for (var i = 0; i < result.rows.length; i++) {
                data[i] = result.rows.item(i);
             }

             options.success(data); // return the data back to the data source
          });
        });
      }
   }
});

这是一个完整的 CRUD 演示:http://jsbin.com/azukin/4/edit

Here is a full CRUD demo: http://jsbin.com/azukin/4/edit

这篇关于如何使用 Kendo UI 查询本地 websql 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆