commit
692522b586
|
@ -183,6 +183,8 @@ define([
|
||||||
|
|
||||||
_options.tpl = _.template(this.template)(_options);
|
_options.tpl = _.template(this.template)(_options);
|
||||||
|
|
||||||
|
this._previewTdWidth = [];
|
||||||
|
this._previewTdMaxLength = 0;
|
||||||
Common.UI.Window.prototype.initialize.call(this, _options);
|
Common.UI.Window.prototype.initialize.call(this, _options);
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
|
@ -417,6 +419,9 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePreview: function() {
|
updatePreview: function() {
|
||||||
|
this._previewTdWidth = [];
|
||||||
|
this._previewTdMaxLength = 0;
|
||||||
|
|
||||||
var encoding = (this.cmbEncoding && !this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() :
|
var encoding = (this.cmbEncoding && !this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() :
|
||||||
((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0);
|
((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0);
|
||||||
var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
|
var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
|
||||||
|
@ -488,15 +493,24 @@ define([
|
||||||
if (str.length>maxlength)
|
if (str.length>maxlength)
|
||||||
maxlength = str.length;
|
maxlength = str.length;
|
||||||
}
|
}
|
||||||
|
this._previewTdMaxLength = Math.max(this._previewTdMaxLength, maxlength);
|
||||||
var tpl = '<table>';
|
var tpl = '<table>';
|
||||||
for (var i=0; i<data.length; i++) {
|
for (var i=0; i<data.length; i++) {
|
||||||
var str = data[i] || '';
|
var str = data[i] || '';
|
||||||
tpl += '<tr style="vertical-align: top;">';
|
tpl += '<tr style="vertical-align: top;">';
|
||||||
for (var j=0; j<str.length; j++) {
|
for (var j=0; j<str.length; j++) {
|
||||||
tpl += '<td>' + Common.Utils.String.htmlEncode(str[j]) + '</td>';
|
var style = '';
|
||||||
|
if (i==0 && this._previewTdWidth[j]) { // set td style only for first tr
|
||||||
|
style = 'style="min-width:' + this._previewTdWidth[j] + 'px;"';
|
||||||
|
}
|
||||||
|
tpl += '<td '+ style +'>' + Common.Utils.String.htmlEncode(str[j]) + '</td>';
|
||||||
}
|
}
|
||||||
for (j=str.length; j<maxlength; j++) {
|
for (j=str.length; j<this._previewTdMaxLength; j++) {
|
||||||
tpl += '<td></td>';
|
var style = '';
|
||||||
|
if (i==0 && this._previewTdWidth[j]) { // set td style only for first tr
|
||||||
|
style = 'style="min-width:' + this._previewTdWidth[j] + 'px;"';
|
||||||
|
}
|
||||||
|
tpl += '<td '+ style +'></td>';
|
||||||
}
|
}
|
||||||
tpl += '</tr>';
|
tpl += '</tr>';
|
||||||
}
|
}
|
||||||
|
@ -511,6 +525,14 @@ define([
|
||||||
}
|
}
|
||||||
this.previewPanel.html(tpl);
|
this.previewPanel.html(tpl);
|
||||||
|
|
||||||
|
if (data.length>0) {
|
||||||
|
var me = this;
|
||||||
|
(this._previewTdWidth.length===0) && this.previewScrolled.scrollLeft(0);
|
||||||
|
this.previewPanel.find('tr:first td').each(function(index, el){
|
||||||
|
me._previewTdWidth[index] = Math.max(Math.max(Math.ceil($(el).outerWidth()), 30), me._previewTdWidth[index] || 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.scrollerX = new Common.UI.Scroller({
|
this.scrollerX = new Common.UI.Scroller({
|
||||||
el: this.previewPanel,
|
el: this.previewPanel,
|
||||||
suppressScrollY: true,
|
suppressScrollY: true,
|
||||||
|
|
Loading…
Reference in a new issue