Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kendo ui Jaydata作为KendoDataSource没有';t在添加新记录时自动刷新_Kendo Ui_Kendo Grid_Jaydata - Fatal编程技术网

Kendo ui Jaydata作为KendoDataSource没有';t在添加新记录时自动刷新

Kendo ui Jaydata作为KendoDataSource没有';t在添加新记录时自动刷新,kendo-ui,kendo-grid,jaydata,Kendo Ui,Kendo Grid,Jaydata,我正在使用jaydata管理一个仅限客户端的数据存储。数据通过信号广播接收。接收到的数据在内存中缓冲。内存缓冲区每秒刷新一次到jaydata存储并保存 绑定到jaydata存储的剑道网格不会自动更新。一旦jaydatasavechanges方法完成,我需要调用数据源上的read方法。下面的代码是计时器启动时调用的方法 $scope.updateGrid = function () { if ($scope.allowUpdate) { var data = $scope.

我正在使用jaydata管理一个仅限客户端的数据存储。数据通过信号广播接收。接收到的数据在内存中缓冲。内存缓冲区每秒刷新一次到jaydata存储并保存

绑定到jaydata存储的剑道网格不会自动更新。一旦jaydatasavechanges方法完成,我需要调用数据源上的read方法。下面的代码是计时器启动时调用的方法

$scope.updateGrid = function () {
    if ($scope.allowUpdate) {
        var data = $scope.scribeMessages.splice(0, $scope.scribeMessages.length);
        if (data.length > 0) {
            scribeDb.Messages.addMany(data);
            scribeDb.saveChanges().then(function () { $scope.scribeGrid.dataSource.read(); });
        }
    }
};
在我的剑道网格中,我定义了如下数据源:

    dataSource: scribeDb.Messages.asKendoDataSource({
        pageSize: 20,
        sort: [{ field: "SequenceId", dir: "desc" }]
    })
我已将实体、实体集和描述定义为:

$data.Entity.extend("ScribeMessage", {
    SequenceId: { type: "string", required: true, key: true, computed: false },
    ScribeId: { type: "string", required: true },
    Environment: { type: "string", required: true },
    LogLevel: { type: "integer", required: true },
    Program: { type: "string", required: true },
    Subject: { type: "string", required: false },
    Message: { type: "string", required: false },
    MachineName: { type: "string", required: true },
    InstanceId: { type: "string", required: false },
    ComponentId: { type: "string", required: false },
    Exception: { type: "string", reguired: false },
    ServerTime: { type: "date", required: true },
    ClientTime: { type: "date", required: true },
    User: { type: "string", required: true }
});

$data.EntityContext.extend("ScribeDatabase", {
    Messages: { type: $data.EntitySet, elementType: ScribeMessage }
});

var scribeDb = new ScribeDatabase({ provider: "indexedDb", databaseName: "ScribeMessages" });
我希望网格绑定的数据源能够自动检测底层数据存储已更改

是否需要强制数据源读取


提前感谢您的帮助。

预计不会检测到更改。这与将电网连接到服务器时,不会收到更改通知的行为相同。您可以使用内置轮询,也可以自己使用推送通知

JayData确实提供了数据更改时的事件,您可以将其挂接到其中,例如我经常使用的事件

context.Dogs.addEventListener('afterUpdate',function(){alert('doggy updated');})

在这种情况下,您可以告诉网格的数据源重新加载。但请确保用户当前没有编辑某些内容。。。我相信这就是JayDATA不强制重载的原因,因为他们不能确定用户不在网格上做一些动作。 祝你玩得开心,杰达和剑道的婚姻有点不稳定