[WARN][Ext.data.Operation#process] Unable to match the record that came back from the server

分类:Javascript| 发布:camnprbubuol| 查看:679 | 发表时间:2013/6/25

 Unable to match the record that came back from the server

看上图,因为修改4次Store中的字段值,所以会显示4次警告:[WARN][Ext.data.Operation#process] Unable to match the record that came back from the server.

出现这个警告的原因是:从服务器返回的数据不能匹配Store里的记录。(字面意思)。 具体就是: 我们在定义store时,例如下边的代码:

1var camnprStore = Ext.create("Ext.data.Store", {
2   fields: ['name', 'count'],
3   data: [{name: '布布', count: 20}, {name: '挎包包', count: 10}, {name: '真男人', count: 15}, {name: 'facklook', count: 60}]
4});

如果我们想修改这里边的count的值。 (一直后台程序C#web接口返回的数据形式是:
{responseCode:1, filesCount: 5, decisionCount: 9, descCount: 20, problemCount: 30 })

那么我们通过Store的getAt先得到某行记录,让回通过set方法修改Store里的值,代码如下:

01var camnprStore = Ext.getStore('Camnpr');
02camnprStore.load(function (records, operation, success) {
03       if (success) {
04           try {
05               Ext.data.JsonP.request({
06                   url: 'http://camnpr.com/',
07                   callbackKey: 'callback',
08                   params: {
09                       user: 'camnpr',
10                       typeid: window.localStorage.getItem('id')
11                   },
12                   success: function (result) {
13                       if (result.responseCode == 1) {
14                           try {
15                               camnprStore.getAt(0).set('count', result.filesCount);
16                               camnprStore.getAt(1).set('count', result.decisionCount);
17                               camnprStore.getAt(2).set('count', result.descCount);
18                               camnprStore.getAt(3).set('count', result.problemCount);
19                                //navsStore.sync();  //如果加上这句,就会报出警告,取消这个就不会显示警告了
20                           } catch (e) { }
21                       }
22                   }
23              });
24           } catch (e) { }
25       }
26   }, this);

针对Store的Add添加记录,会不会也报出这个错误。解决方法应该一样。 如果你也遇到这个错误,此方法不行的话,欢迎留言。

365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/javascript/Unable-to-match-the-record-that-came-back-from-the-server.html