dqwyghl0649 2010-07-19 16:41 采纳率: 0%
浏览 34
已采纳

JSONstore无法正确返回数据

I've had this problem for awhile now, but I keep narrowing down the issue and I think I have main problem figured out now. While my JSONstore calls to the PHP correctly, and firebug does give me the correct data back from the database, it will not display in my grid.

I have a grid with only 2 columns a date, and an entry from a log. When I take out the log entry, the grid will display the date just fine, and when I just create an array with static data from the log then it will display fine in the grid as well. I think my JSONstore just isn't parsing the data correctly from the mysql tables.

My code is:

  var logStore = new Ext.data.JsonStore({
    autoLoad: true,
    url: 'inc/interface/config.php?list=messages',
    root: 'dates',
    idProperty: 'ID',
    fields: ['ID', 'ReceivedAt', 'Message'],
    listeners: {
                loadexception: function() {
                    console.log('load failed -- arguments: %o', arguments);
                }
        }
}); 

  var logGrid = new Ext.grid.GridPanel({
        region: 'center',
        store: logStore,
        colModel: new Ext.grid.ColumnModel({
            columns: [{
                id: 'received',
                header: 'Received',
                dataIndex: 'ReceivedAt',
                width: 250
            },{
                id: 'message',
                header: 'Logs',
                dataIndex: 'Message',
                width: 750
            }]
        })
    });

An example of the log entry it's pulling is:

| Apr 9 00:00:02 dh1 dhcpd: Added new forward map from nfxxxxich-PC.wifi-uhs.osu to 10.xxx.xx.248 |
| Apr 9 00:00:02 dh1 dhcpd: added reverse map from 248.xxxx.xxx.10.in-addr.arpa. to nxxxxxh-PC.wifi-uhs.osu |
| Apr 9 00:00:02 dh1 dhcpd: DHCPREQUEST for 10.xxx.xxx.248 from 00:x:5c:x:8c:xx (nxxxxh-PC) via 10.xxx.xxx.254 |
| Apr 9 00:00:02 dh1 dhcpd: DHCPACK on 10.X.XX.248 to 00:X:5c:X8c:XX (nXXXich-PC) via 10.193.XX.XXX |
| Apr 9 00:00:02 dh1 dhcpd: Added new forward map from XX.wifi-uhs.XXX to 10.X.X.242 |
| Apr 9 00:00:02 dh1 dhcpd: added reverse map from 242.X.193.X.in-addr.arpa. to X.wifi-uhs.XXX |
| Apr 9 00:00:02 dh1 dhcpd: DHCPREQUEST for 10.X.X.242 from 00:X:ce:X21:63 (elena) via 10.X.X.254 |
| Apr 9 00:00:02 dh1 dhcpd: DHCPACK on 10.193.XXX.XX to 00:X:ce:X:21:63 (elena) via 10.X.X.254 |
| Apr 9 00:00:02 dh1 dhcpd: Added new forward map from P305-XXX.wifi-uhs.XXX to 10.193.X.X |
| Apr 9 00:00:02 dh1 dhcpd: added reverse map from 21.241.X.X.in-addr.arpa. to P305-XXXX.wifi-uhs.XXX |

There are various different characters and tabs between the date, dh1, and the log entry itself. Could there be an issue with escaping these characters? I'm just not quite sure how it's done. Any help would be appreciated.

  • 写回答

2条回答 默认 最新

  • dongqiao1888 2010-07-19 16:52
    关注

    You haven't specified the type and format in fields. And I'm guessing that your php json implementation doesn't generate a javascript Date object.

    So... try returning an unix timestamp and use this as fields:

    fields: [
      {name: 'ID', type: 'int'},
      {name: 'ReceivedAt', type: 'date', dateFormat: 'Y-m-d H:i:s'},
      'Message'
    ]
    

    Optionally you could also specify a dateFormat next to the type: 'date'. See the documentation for more info: http://www.sencha.com/deploy/dev/docs/?class=Ext.data.Field

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错