I would like to know if there is any way to get html representation of progressbar before it’s rendered anywhere?
I need to render progressbar in a grid. As for now I use custom renderer for progress column:
renderer: function( value, metaData, record, rowIndex, colIndex, store ) {
var id = Ext.id();
(function(){
var progress = new Ext.ProgressBar({
renderTo: id,
value: progress_value
});
}).defer(50);
return '<div id="'+ id + '"></div>';
}
But it doesn’t look user friendly, because progressbars render after grid has been rendered.
I think that it’s possible to create custom progressbar with this functionality as one can see template source code that is rendered into html, but it’s not so elegant I think.
The best thing would be create function like this, I think:
var generateRenderer = (function(){
var pb = new Ext.ProgressBar();
return function( progress_value ){
pb.updateValue( progress_value );
return pb.htmlRepresentationFunction();
}
})();
Where htmlRepresentationFunction() is the function that returns html represetation (as obvious from it’s name). And then use generateRenderer() function in custom renderer.
As for now I’ve rewritten the code this way:
This template is from ProgressBar.js. And then I use this function in my custom renderer like this:
So as I don’t need animation it works, but still I hope there is some way much more elegant than this one.