如何使用Kendo UI查询本地Websql数据库 [英] How to query a local websql DB with Kendo UI
问题描述
如果这个问题对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 mobile,并试图找到在kendo ui mobile中创建/查询本地客户端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屋!