0

I am having an issue related to "stop running this script a script on this page is causing your web browser to run slowly" using IE 8.What exactly i am trying to do is loading large number of rows from database logic and binding it to the jqgrid on the client side.

Client Side Code-

$(document).ready(function () {

        var model = @Html.Raw( POSWebManager.MvcApplication.Serializer.Serialize( Model ) );

        var boolRenderer = function( row, column, value ) {
            var html = "<div style='overflow: hidden; text-overflow: ellipsis; text-align: left; padding:4px 4px 2px 2px;";

            if( value === true ) {
                if( column == "Exported" ) {
                    html += "font-weight:bold;background-color:#99FF66;";
                } else if( column == "HasErrors" ) {
                    html += "font-weight:bold;background-color:#FF9999;";
                }
            }

            html += "'>";
            if( value === true ) {
                html += "Yes";
            } else {
                html += "No";
            }

            html += "</div>";
            return html;
        };

        var columns = [
  { name: "ID", text: 'ID', datafield: 'ID', width: 55 },
  { name: "TransactionItemID", text: 'Trans Item ID', datafield: 'TransactionItemID' },
  { name: "Exported", text: 'Exported', datafield: 'Exported', cellsrenderer: boolRenderer },
  { name: "HasErrors", text: 'Has Errors', datafield: "HasErrors", cellsrenderer: boolRenderer },
  { name: "FirstName", text: 'First Name', datafield: 'FirstName', width: 110, type: "string" },
  { name: "LastName", text: 'Last Name', datafield: 'LastName', width: 110, type: "string" },
  { name: "DOB", text: 'DOB', datafield: 'DOB', width: 90, type: "string" },
  { name: "IDNumber", text: 'ID Number', datafield: 'IDNumber', width: 110, type: "string" },
  { name: "StreetAddress", text: 'Street Address', datafield: 'StreetAddress', width: 150, type: "string" },
  { name: "City", text: 'City', datafield: 'City', width: 130, type: "string" },
  { name: "State", text: 'State', datafield: 'State', width: 70, type: "string" },
  { name: "Post", text: 'Post', datafield: 'PostalCode', width: 70, type: "string" },
  { name: "Email", text: 'Email', datafield: 'Email', width: 150, type: "string" },
  { name: "Created", text: 'Created', datafield: 'Created', width: 90, type: "string" },
  { name: "Updated", text: 'Updated', datafield: 'Updated', width: 90, type: "string" },
              { name: "ABN", text: 'ABN Number', datafield: 'ABN', width: 100, type: "string" },
     { name: "CompanyName", text: 'Company Name', datafield: 'CompanyName', width: 100, type: "string" }
        ];

        var adapter= new $.jqx.dataAdapter( { localdata: model,  datatype: "json",  datafields: columns } );

        $("#jqxgrid").jqxGrid( {
            width: 960,
            source:adapter,
            theme: getDemoTheme(),
            pageable: true,
            autoheight: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            showfilterrow: true,
            filterable: true,
            columnsresize: true,
            selectable: true,
            pagesize: 25,
            pagesizeoptions: ['25', '50', '100', '1000'],
            selectionmode: 'multiplerowsextended',
            columns: columns

        } );
    } );

Can anyone tell me how to disable this notification

Without using with registry or using ActiveX. I am very new to jqgrid and jquery so please help me out on this.

Thanks

nik_boyz
  • 165
  • 3
  • 15

1 Answers1

0

You can't disable the long running or non-responsive script notification. You can work-around it by changing your code.

The usual work-around to a long running process is to break the work into chunks that are short enough that they won't trigger the warning, then process one chunk of work, the do a setTimeout(fn, 1) to process the next chunk and so on until all chunks are done. This requires keeping some simple state variables to guide each chunk.

The setTimeout() allows the browser to process any other pending events and prevents the long running script message.

In this answer: Best way to iterate over an array without blocking the UI, you will see a code example for how to process work in chunks like this. There's even a working jsFiddle in that answer that illustrates the concept.

In your specific case, you could create a state variable for an index into the columns array and then process only a couple columns in each chunk of work, incrementing the index appropriately and when the setTimeout() fires, you process the next few columns and so on.

Community
  • 1
  • 1
jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • i am still not getting it how to do it, what should i put in do chunk method and how to initiate processLargeArray() method in a jqgrid method.Can you please guide me – nik_boyz Mar 26 '14 at 09:50