Ext.define('Sencha.model.Company', { extend: 'Ext.data.Model', idProperty: 'company', fields: [ { name: 'company' }, { name: 'price', type: 'float' },{ name: 'progress', type: 'int' }, { name: 'change', type: 'float' }, { name: 'pctChange', type: 'float' }, { dateFormat: 'n/j h:ia', name: 'lastChange', type: 'date' } ] });
列表中进度列code:
{ xtype: 'gridcolumn', width: 110, dataIndex: 'progress', text: '进度', renderer: function (value, metaData, record) { var id = Ext.id(); metaData.tdAttr = 'data-qtip="'+value+'%"'; Ext.defer(function () { Ext.widget('progressbar', { renderTo: id, value: value / 100, height:20, width: 100, text:value+'%' }); }, 50); return Ext.String.format(' <div id="{0}"></div> ', id); } }
这边还有用到Ext.id(),生成唯一的id,展示进度条用到的div;
tdAttr之前有提过,
text:在进度条中显示的内容,查看progress bar的api,还有个更新进度条的方法,今天也有用到:
updateProgress( [Number value], [String text], [Boolean animate] ) : Ext.ProgressBar Updates the progress bar value, and optionally its text. If the text argument is not specified, any existing text value will be unchanged. To blank out existing text, pass ''. Note that even if the progress bar value exceeds 1, it will never automatically reset -- you are responsible for determining when the progress is complete and calling reset to clear and/or hide the control. Parameters value : Number (optional)//进度条的值 A floating point value between 0 and 1 (e.g., .5) Defaults to: 0 text : String (optional)//进度条中显示的内容 The string to display in the progress text element Defaults to: "" animate : Boolean (optional)//动画效果 Whether to animate the transition of the progress bar. If this value is not specified, the default for the class is used Defaults to: false Returns Ext.ProgressBar this
转自:http://joyliu.org/blog/archives/175