Extjs Widget
2015-12-23 19:12
609 查看
widget column是用一个widget 配置参数指定xtype,表示该widget或component属于column中的cell内容。当一个widget cell 描画的时候,会将widget或component描画这个cell里。
sample:
效果图
代码:
sample:
效果图
代码:
var grid = new Ext.grid.Panel({ title: 'Substation power monitor', width: 600, columns: [{ text: 'Id', dataIndex: 'id', width: 120 }, { text: 'Rating', dataIndex: 'maxCapacity', width: 80 }, { text: 'Avg.', dataIndex: 'avg', width: 85, formatter: 'number("0.00")' }, { text: 'Max', dataIndex: 'max', width: 80 }, { text: 'Instant', dataIndex: 'instant', width: 80 }, { text: '%Capacity', width: 150, // This is our Widget column <strong> xtype: 'widgetcolumn', dataIndex: 'capacityUsed', // This is the widget definition for each cell. // Its "value" setting is taken from the column's dataIndex widget: { xtype: 'progressbarwidget', textTpl: [ '{percent:number("0")}% capacity' ] }</strong> }], renderTo: document.body, disableSelection: true, store: { fields: [{ name: 'id', type: 'string' }, { name: 'maxCapacity', type: 'int' }, { name: 'avg', type: 'int', calculate: function(data) { // Make this depend upon the instant field being set which sets the sampleCount and total. // Use subscript format to access the other pseudo fields which are set by the instant field's converter return data.instant && data['total'] / data['sampleCount']; } }, { name: 'max', type: 'int', calculate: function(data) { // This will be seen to depend on the "instant" field. // Use subscript format to access this field's current value to avoid circular dependency error. return (data['max'] || 0) < data.instant ? data.instant : data['max']; } }, { name: 'instant', type: 'int', // Upon every update of instantaneous power throughput, // update the sample count and total so that the max field can calculate itself convert: function(value, rec) { rec.data.sampleCount = (rec.data.sampleCount || 0) + 1; rec.data.total = (rec.data.total || 0) + value; return value; }, depends: [] }, { name: 'capacityUsed', calculate: function(data) { return data.instant / data.maxCapacity; } }], data: [{ id: 'Substation A', maxCapacity: 1000, avg: 770, max: 950, instant: 685 }, { id: 'Substation B', maxCapacity: 1000, avg: 819, max: 992, instant: 749 }, { id: 'Substation C', maxCapacity: 1000, avg: 588, max: 936, instant: 833 }, { id: 'Substation D', maxCapacity: 1000, avg: 639, max: 917, instant: 825 }] } });
相关文章推荐
- jstl中格式化时间戳
- JavaScript中concat不起作用
- 測试JSON RPC远程调用(JSONclient)
- 轻松学习JavaScript二十五:DOM编程学习之操作CSS样式(二)
- browserify.js 的模块加载
- 常用JS验证函数总结
- js 同步和异步共存的示例
- JavaScript_通过onmouseover onmouseout 部分显示与隐藏
- js获取url参数 兼容某些带#url
- JavaScript中定时器问题与解决方法
- 编写原生JS的insertAfter函数
- js 获取浏览器高度和宽度值(多浏览器)
- 重新加载验证码的js
- javascript预加载图片方法汇总
- ArcGIS JavaScript API 4.0beta 3
- HTML用JS导出Excel的五种方法
- Javascript题之你还是不懂js
- javascript正则匹配中文
- JavaScript基础——html5脚本编程
- JS中的List