我是第一次学习EXT Js和示例http://examples.sencha.com/extjs/6.2.0/examples/kitchensink/#array-grid我试图找出如何填充表并找不到表内容的来源。 以前任何使用过EXT Js的人都应该发现寻找数据源的重要性,或者推荐如何以及如何在像jsfiddle这样的平台上测试extjs。EXT JS如何获取数据
0
A
回答
2
您可以通过许多过程获取网格数据。
第一种方式是将数据绑定到代码本身。
但在此之前,如何绑定数据以及它如何在网格中工作,您需要创建data store
,然后将此存储绑定到您的网格store
。
下面是一个例子代码:
Ext.create('Ext.data.Store', {
storeId: 'simpsonsStore',
fields:[ 'name', 'email', 'phone'],
data: [
{ name: 'Lisa', email: '[email protected]', phone: '555-111-1224' },
{ name: 'Bart', email: '[email protected]', phone: '555-222-1234' },
{ name: 'Homer', email: '[email protected]', phone: '555-222-1244' },
{ name: 'Marge', email: '[email protected]', phone: '555-222-1254' }
]
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
这里是煎茶捣鼓你。 Sencha Fiddle
您可以从JSON或XML获取数据的第二种方式。在这种情况下,您还必须创建一个data store
(可能是json store或Array store),然后再绑定到网格。只有数据部分会改变。在这里你需要通过使用一些Ajax调用从json中获取数据。
以下是示例代码。
var store = new Ext.data.JsonStore({
// store configs
storeId: 'myStore',
proxy: {
type: 'ajax',
url: 'get-images.php',
reader: {
type: 'json',
rootProperty: 'images'
}
},
//alternatively, a Ext.data.Model name can be given (see Ext.data.Store for an example)
fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
});
然后调用你的绑定你的商店,就像我们在前面的代码中做的那样。 我会建议你请通过此链接
有用的链接
Grid PAnel _网格面板 Data Store - 数据存储 JSON STore
相关问题
- 1. Ext JS 3:从fileuploadfield获取数据
- 2. EXT-JS数据关联
- 3. Ext JS的数据转换
- 4. 在Ext JS表单中未获取数据面板
- 5. 在Ext JS 3.0 Grid中获取行数据
- 6. 如何从JSP获取数据到js
- 7. Ext JS - 如何从ViewModel中获取应用程序的名称?
- 8. 如何在ext js中获取此json对象中的值?
- 9. Ext JS:获取调用函数的名称
- 10. 从EXT js 3.4移植到EXT js 5.0
- 11. Ext JS 6从Ext JS 4.1.3迁移到
- 12. 如何将数据从Django传输到Ext JS
- 13. 如何获取Ext Tree childNodes的ID?
- 14. Ext JS 4:从XML字符串读取数据
- 15. 如何使用draft-js从数据库获取/保存数据
- 16. Ext js许可
- 17. Ext JS UX - RowPanelExpander
- 18. Window.open()in ext Js
- 19. 缺点ext js
- 20. HTML ext js fieldsets
- 21. Ext JS - A start
- 22. Ext JS Cascading Combobox
- 23. 如何最小化Ext JS/Ext甘特文件夹的生产?
- 24. d3.js如何获取对象数据数组的总和?
- 25. 如何从JS函数获取数据到控制器类
- 26. Ext JS 4 - 如何获取特定选项卡并插入内容(查看)
- 27. 如何获取Ext JS中提交事件的粒子字段验证?
- 28. 如何覆盖Ext JS JsonStore超时?
- 29. Ext JS - 如何创建语法
- 30. 如何获取数组值js