jQWidgets Forums

jQuery UI Widgets Forums Grid ReferenceError: data is not defined

This topic contains 1 reply, has 1 voice, and was last updated by  RedantJ 9 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • ReferenceError: data is not defined #78759

    RedantJ
    Participant

    Hey guys, new project, new code (edited for this post), new problem:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <META HTTP-EQUIV="X-UA-Compatible" CONTENT="IE=edge,chrome=1">
        <title id='Description'>Foo Reports</title>
        <link rel="stylesheet" href="./jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="./scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxgrid.filter.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxgrid.sort.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxpanel.js"></script>
        <script type="text/javascript" src="./jqwidgets/jqxcheckbox.js"></script>
    	<script type="text/javascript" src="./scripts/demos.js"></script>
    	<script tpye="text/javascript">
    	    $(document).ready(function () { 
    		
                var sortdata = new Array();
    
    		var idxUID = ["0","1","2"];
    		var foo1 = ["11","22","33"];
    		var foo2 = ["Mary","Joseph","Hans"];
    
                for (var i = 0; i < arrayLength; i++) {
                    var row = {};
    		row["idxUID"] = idxUID[i];
    		row["foo1"] = foo1[i];
                    row["foo2"] = foo2[i];
                    sortdata[i] = row;
    	    }
    	});
    		
                var source =
                {
                    localdata: sortdata,
                    datatype: "array",
    			datafields:
    			[
    				{ name: 'idxUID' },
    				{ name: 'foo1', type: 'string' },
    				{ name: 'foo2', type: 'string' }
    			],
    			};			
    			
    			var dataAdapter = new $.jqx.dataAdapter(source);
    
    	$("#jqxgrid").jqxGrid(
                {
                    width: 400,
                    source: dataAdapter,
                    showfilterrow: true,
                    filterable: true,
                    selectionmode: 'multiplecellsextended',
                    columns: [
                      { text: 'Foo 1', columntype: 'textbox', filtertype: 'input', datafield: 'foo1', width: 200 },
                      { text: 'Foo 2', columntype: 'textbox', filtertype: 'input', datafield: 'foo2', width: 200 }
                    ]
                });
                $('#clearfilteringbutton').jqxButton({ height: 25});
                $('#clearfilteringbutton').click(function () {
                    $("#jqxgrid").jqxGrid('clearfilters');
                });		
    	</script>
    	
    </head>
    <body class='default'>
    	<div id="jqxgrid">
    	</div>
    	<input style="margin-top: 10px;" value="Remove Filter" id="clearfilteringbutton" type="button" />
    </body>
    </html>

    I removed all of the ASP Classic code for this post. So anyway, here’s the problem. This is throwing out the following error:

    Uncaught ReferenceError: sortdata is not defined

    At this line:

    localdata: sortdata,

    How can this be? I defined sortdata here:

    var sortdata = new Array();

    Any ideas?

    ReferenceError: data is not defined #78760

    RedantJ
    Participant

    …well, (grunt)…I had:

    });

    placed at the wrong place in the code.

    That had the effect of closing off:

    $(document).ready(function () {

    Watch for that, programmers. It’s an easy error to make.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.