Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very slow performance in IE with large data set #18

Open
tpcrr opened this issue Nov 16, 2012 · 2 comments
Open

Very slow performance in IE with large data set #18

tpcrr opened this issue Nov 16, 2012 · 2 comments

Comments

@tpcrr
Copy link

tpcrr commented Nov 16, 2012

I was seeing a > 30 second load time for a 2,000 row data set.

I tracked down the offending code in the fnDraw method.

$.each(aDistinctOptions, function (i, sOption) {
    var sText;
    sText = $('<div>' + sOption + '</div>').text();
    widget.$Select.append($('<option></option>').attr('value', sOption).text(sText));
});

Both the jQuery append and each are fairly slow in IE when used this way. I did some searching and found an improvement to this code.

var iLength = aDistinctOptions.length;
var aOptions = [];
var i = 0;
for (var a = 0; a < iLength; a += 1) {
    aOptions[i++] = '<option value="';
    aOptions[i++] = aDistinctOptions[a];
    aOptions[i++] = '">';
    aOptions[i++] = aDistinctOptions[a];
    aOptions[i++] = '</option>';
}
widget.$Select.append(aOptions.join(''));

I hope this can help someone else out.

@Muhahe
Copy link

Muhahe commented Nov 28, 2012

Hi, maybe im retarded, but when i use your option, performance rapidly go down for me :(

My function is this

$.each( aDistinctOptions, function( i, sOption ) {

                var sText; 
                sText = $( '<div>' + sOption + '</div>' ).text();

                                if(widget.oColumn.sTitle == 'Start' || widget.oColumn.sTitle == 'End'){
                                var czDate = sText.split('.'); 
                                if(czDate[0].length == 1){
                                    czDate[0] = '0'+czDate[0]; 
                                }
                                var czDateParsed = (czDate[2]+czDate[1]+czDate[0]);

                                widget.$Select.append( $( '<option class="sortable"></option>' ).attr( 'value', sOption ).attr( 'data-sort', czDateParsed).text( sText ) );    
                                }else{ 
                widget.$Select.append( $( '<option class="sortable"></option>' ).attr( 'value', sOption ).attr( 'data-sort', sText).text( sText ) );
                                }
            //pridano pokus o sort data


            } );

But when i make it

$.each( aDistinctOptions, function( i, sOption ) {
var iLength = aDistinctOptions.length;
var aOptions = [];
var i = 0;
for (var a = 0; a < iLength; a += 1) {
    aOptions[i++] = '<option value="';
    aOptions[i++] = aDistinctOptions[a];
    aOptions[i++] = '">';
    aOptions[i++] = aDistinctOptions[a];
    aOptions[i++] = '</option>';
}
widget.$Select.append(aOptions.join(''));

  } );

Am i doing something terribly wrong?

@skarv
Copy link

skarv commented Oct 10, 2014

@cyberhobo: I can fully support @tpcrr's suggestion - I've implemented it in my code, and ColumnFilterWidgets performs better in IE11. The difference becomes very notable with 500+ rows. How about replacing the other $.each methods that slows IE 11 down with large datasets as well? In a current project with 500+ rows, ColumnFilterWidgets sadly drags the page load time down from 4 seconds to 20 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants