We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2611
    • 394 Posts
    I’ve created a datagrid using a HttpProxy but it won’t load my data.
    I’ve verified that it actually does the request with FireBug but the
    data won’t load. No errors, no nothing.

    My JS code:
    Ext.onReady(function() {
    
    	var proxy = new Ext.data.HttpProxy( {
    		url : '../connectors/testcomponent/ajax.php?action=grid'
    	});
    	// Define the reader 
    		var reader = new Ext.data.JsonReader( {
    			totalProperty: 'total',
    			root: 'results',
    			id: 'id'
    		});
    		// Build a Store 
    		var store = new Ext.data.Store( {
    			proxy : proxy,
    			reader : reader
    		});
    		// Load 
    		store.load();
    
    		// create the grid
    		var grid = new Ext.grid.GridPanel( {
    			store : store,
    			columns : [ {
    				header : "Name",
    				width : 120,
    				dataIndex : 'name',
    				sortable : true
    			}, {
    				header : "Occupation",
    				width : 120,
    				dataIndex : 'occupation',
    				sortable : true
    			}],
    			renderTo : 'mygrid',
    			width : 540,
    			height : 200
    		});
    
    });
    


    The response:
    { 'total': 2, 'results': [ { 'id': 1, 'name': 'Test', occupation: 'test 2' }, { 'id': 2, 'name': 'test 4', occupation: 'test 5' } ] }
    
      Follow me on twitter: @b03tz
      Follow SCHERP Ontwikkeling on twitter: @scherpontwikkel
      CodeMaster
      • 2611
      • 394 Posts
      Ah, i see. I forgot to add the second property to the new JsonReader:

      var Employee = Ext.data.Record.create([
      		    {name: 'name'},                
      		    {name: 'address'}  
      ]);


      which then results into:
      var reader = new Ext.data.JsonReader({
      			totalProperty: 'total',
      			root: 'results',
      			id: 'id'	
      		}, Employee);


      Thanks anyway smiley

      For other people struggling with the fact that their data doesn’t show up, it would also seem
      if i don’t add the height values to the grid config it doesn’t show any values at all. It does
      show the column headers and the full GRID border.
        Follow me on twitter: @b03tz
        Follow SCHERP Ontwikkeling on twitter: @scherpontwikkel
        CodeMaster