如何使用.log数据文件显示EXT-js网格
How to show EXT js Grid with .log data file?
我有一个.log文件。我在EXTJS中创建了一个网格示例来显示json文件中的日志数据(模拟数据)。现在我想显示.log文件中的网格数据。最好的方法是什么?可以将.log文件转换为.json文件(通过解析或说somwhow),或者有更好/明智的方法吗?
我认为您需要通过Ajax请求以不同的方式获取数据。
// Should work also in newer ExtJS versions
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
width: 640,
height: 480,
store: new Ext.data.ArrayStore({
fields: ['id', 'val1', 'val2'],
data: []
}),
columns: [{
dataIndex: 'id',
text: 'Id'
}, {
dataIndex: 'val1',
text: 'Value #1'
}, {
dataIndex: 'val2',
text: 'Value #2'
}],
listeners: {
afterrender: function(grid) {
// Do an Ajax request
Ext.Ajax.request({
url: 'data1.log',
// Will go here, because there is no such file...
// When you provide a file it will be success and you can handle failure differently
failure: function(response) {
// responseText will be response.responseText on success
// this here is only a mock
var responseText = "id1'tval1a'tval1b'nid2'tval2a'tval2b'nid3'tval3a'tval3b",
data = [];
// Split your data on new lines and iterate
Ext.each(responseText.split(''n'), function (record) {
// Create an empty array
var item = [];
// Split your new line-split on tab and iterate
Ext.each(record.split(''t'), function (recordItem) {
// push to your new data item
item.push(recordItem);
});
// push to your data
data.push(item);
});
// load the store
grid.store.loadRawData(data);
}
});
}
}
});
我提供了一个关于jsfiddle的例子:http://jsfiddle.net/4Lx818ua/
祝你好运。
相关文章:
- Ext.js从json构建模型关系的问题
- 在HTML页面上显示node.js服务器中的数据
- 在EXT窗体面板中填充EXT JS存储
- 是否可以将JXBrowser显示的JS确认对话框的结果返回到调用它的JS部分
- 从Sencha Touch迁移到EXT JS 6-Contoller的默认/空路由
- 如何使用.log数据文件显示EXT-js网格
- 根据屏幕大小显示主干.js集合的子集
- Sencha Ext JS排序标准以字符串而不是JSON的形式发送
- 条件显示淘汰js
- 在 EXT JS 中显示窗口
- Ext-js 在分机日期菜单中显示星期一的日历
- 在 Ext JS 4 上显示/隐藏系列的单个行元素
- EXT JS :在组合框中,如何为不在存储中的记录设置显示字段
- 在Ext.js/Sencha Touch中显示数学符号
- 如何在ext-js网格中将记录数据显示为链接
- Ext JS 4复选框字段未显示
- Ext JS:无论浏览器时区如何,都以UTC显示日期
- Ext js网格问题显示日期在safari
- 使用 ext js 4.1 突出显示网格中的一行
- 使用Ext js在网格中只显示有限的记录