jQWidgets Forums

jQuery UI Widgets Forums Grid Nested Grip using PHP error

This topic contains 5 replies, has 2 voices, and was last updated by  Peter Stoev 9 years, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Nested Grip using PHP error #82542

    goldie
    Participant

    Hello,

    I followed the demo under PHP demos for server side grid with nested grid.
    However, I get a syntax error in the for loop. Can someone please let me know what I did wrong?

    <script type="text/javascript">
    	var $jsquery = jQuery.noConflict();
    	
    	$jsquery(document).ready(function () 
    	{
    
    		var source =
    		{
    				datatype: "json",
    				cache: false,
    				datafields: [
    					{ name: 'cID', type: 'number'},
    					{ name: 'ipAddress', type: 'string'},
    					{ name: 'cName', type: 'string'},
    					{ name: 'poc', type: 'string'}						
    				],
    				id: 'cID',
    				url: 'testNData.php',
    				root: 'Rows',
    				cache: false,
    				beforeprocessing: function (data) 
    				{
    					source.totalrecords = data[0].TotalRows;
    				},
    				sort: function()
    				{
    					$jsquery("#jqxgrid").jqxGrid('updatebounddata', 'sort');
    				}			
    		};		
    			
    		var dataAdapter = new $jsquery.jqx.dataAdapter(source);
    		
    		var initrowdetails = function (index, parentElement, gridElement) 
    		{      
    			var row = index;
    			var id = $jsquery("#jqxgrid").jqxGrid('getrowdata', row)['cID'];
    			var grid = $jsquery($jsquery(parentElement).children()[0]);
    					
    			var source =
    			{
    				url: 'testNData.php',
    				datatype: "json",
    				data: {countID: id},
    				cache: false,
    				datafields: [
    					 { name: 'plugin' },
    					 { name: 'plugName' },
    					 { name: 'vDate' },
    					 { name: 'severity' }
    				],
    				root: 'Rows',
    				beforeprocessing: function (data) 
    				{
    					source.totalrecords = data[0].TotalRows;
    				},     
    				sort: function()
    				{
    					grid.jqxGrid('updatebounddata', 'sort');
    				}
    			};
    			
    			var adapter = new $jsquery.jqx.dataAdapter(source);
    			
    			// init Orders Grid
    			grid.jqxGrid(
    			{
    				virtualmode: true,
    				height: 190,
    				width: 530,
    				sortable: true,
    				pageable: true,
    				pagesize: 5,
    				source: adapter,
    				rendergridrows: function (obj) 
    				{
    					return obj.data;
    				},
    				columns: [
    						{ text: 'Plugin', datafield: 'plugin', width: 200 },
    						{ text: 'Plugin Name', datafield: 'plugName', width: 200 },
    						{ text: 'Vulnerability Date', datafield: 'vDate', width: 180 },
    						{ text: 'Severity', datafield: 'severity', width: 100 }
    					]
    			});
    		}; //end init order
    
    		// set rows details.
    		$jsquery("#jqxgrid").bind('bindingcomplete', function (event) 
    		{
    			if (event.target.id == "jqxgrid") 
    			{
    				$jsquery("#jqxgrid").jqxGrid('beginupdate');
    				var datainformation = $jsquery("#jqxgrid").jqxGrid('getdatainformation');
    				<strong>for (i = 0; i < datainformation.rowscount; i++)</strong> 
    				{
    					$jsquery("#jqxgrid").jqxGrid('setrowdetails', i, "<div id='grid" + i + "' style='margin: 10px;'></div>", 220, true);
    				}
    				$jsquery("#jqxgrid").jqxGrid('resumeupdate');
    			}
    		});	 //end set row details
    			
    		$jsquery("#jqxgrid").jqxGrid(
    		{
    			source: dataAdapter,
    			pageable: true,
    			sortable: true,
    			autoheight: true,
    			virtualmode: true,
    			rowdetails: true,
    			initrowdetails: initrowdetails,
    			rendergridrows: function () 
    			{
    					return dataAdapter.records;
    			},				
    			columns: [
    				{ text: 'IP Address', datafield: 'ipAddress', width: 250},
    				{ text: 'Computer Name', datafield: 'cName', width: 150 },
    				{ text: 'POC', datafield: 'poc', width: 180 }								
    				]
    		}); 	
    	});
    </script>
    	    
    <div id="jqxWidget" style="width:100%;">
    	<div id="jqxgrid"></div>
    </div>

    The bold line is where it is complaining that it is a syntax error.

    Thanks,

    goldie

    Nested Grip using PHP error #82543

    Peter Stoev
    Keymaster

    Hi goldie,

    Yes, you have a syntax error there. See: <strong>for (i = 0; i < datainformation.rowscount; i++) {</strong>. This is invalid.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Nested Grip using PHP error #82544

    goldie
    Participant

    Peter,

    I’m sorry. I was trying to bold the line that was causing the error. It is not in the actual script.

    –goldie

    Nested Grip using PHP error #82546

    Peter Stoev
    Keymaster

    You are missing also var before the “i”. Also if it’s php error, would not it better to debug your php code?

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Nested Grip using PHP error #82548

    goldie
    Participant

    Peter,

    Even when I put the var before the i, it is still a problem.

    When I remove the code:

    for (i = 0; i < datainformation.rowscount; i++) 
    {
    	$jsquery("#jqxgrid").jqxGrid('setrowdetails', i, "<div id='grid" + i + "' style='margin: 10px;'></div>", 220, true);
    }

    I get the grid with “no data to display”.

    When I add the code:

    var datainformation = $jsquery("#jqxgrid").jqxGrid('getdatainformation');
    alert(datainformation.rowscount+" is the count");

    The pop-up say that the datainformation.rowscount is 0. That can’t be right, right?

    What could be causing that to be 0?

    –goldie

    Nested Grip using PHP error #82549

    Peter Stoev
    Keymaster

    Hi goldie,

    It could be right, if your URL is incorrect or if your PHP returns no data. I suggest you to check whether the URL is correct and to debug your php code.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.