I have an application which is used for data analysis and I\'m having a few performance issues with the creation of the table. The data is extracted from documents and it is
You can do couple of things to increase the performance:
$.each() function and each function you append the element into DOM. But this is minor adjustment.$(' ').But try to avoid storing the value. Your DOM size will be huge but it should work on moder browsers and forget about IE6.
@fuel37 : Example
function outputDocumentNew(data, doc_id) {
//Variable DOM's
var rowSample = $(' ').addClass('row-class');
var colSample = $(' ').addClass('col-class');
var spanSample = $('').addClass('span-class');
var inputButtonSample = $('').addClass('input-class');
//DOM Container
var container = $('#documentRows');
container.empty().append('
');
//Static part
var head = '\
\
ID \
Status \
Name \
Actions \
Origin \
\
';
container.append(head);
var body = $('');
container.append(body);
//Dynamic part
$.each(data, function (index, value) {
var _this = this;
//DOM Manupulation
var row = rowSample.clone();
//Actions
var inpFailOne = inputButtonSample.clone().val('F').attr('rev', _this.id).addClass('failOne').click(function (e) {
//do something when click the button.
});
var inpPromoteOne = inputButtonSample.clone().val('P').attr('rev', _this.id).addClass('promoteOne').click(function (e) {
//do something when click the button.
});
row
.append(colSample.clone().append(_this.id))
.append(colSample.clone().append(spanSample.colne().addClass('status').append(_this.status)))
.append(colSample.clone().append(spanSample.colne().addClass('name').append(_this.name)))
.append(colSample.clone().append(inpFailOne).append(inpPromoteOne))
.append(colSample.clone().append(_this.origin));
body.append(row);
});
}
in this process you need to create & maintain id's or classes for manipulation. You have the control to bind events and manipulate each elements there.