0
votes

I'm getting from php an json encoded

{
     "employees": [{
         "Employee_ID": "1",
         "Department_ID": "2",
         "Name": "Bagio",
         "Email": "[email protected]"
     }, {
         "Employee_ID": "2",
         "Department_ID": "2",
         "Name": "Sinchan",
         "Email": "[email protected]"
     }]
 }

When I try to load it I get no response. This is my ExtJs 4.2 code

Ext.onReady(function() {
    Ext.define('Person', {
        extend: 'Ext.data.Model',
        fields: [
            'Employee_ID', 'Department_ID', 'Name', 'Email'
        ]
    });

    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
        model: 'Person',
        autoLoad: true,
        proxy: {
            type: 'memory',
            url: 'example.php',
            reader: {
                type: 'json',
                root: 'employees'
            }
        }
    });
    store.load();
    Ext.create('Ext.grid.Panel', {
        store: store,
        columns: [{
                text: "Employ_id",
                width: 120,
                dataIndex: 'Employee_ID'
            },
            {
                text: "Department_ID",
                width: 380,
                dataIndex: 'Department_ID'
            },
            {
                text: "Name",
                width: 380,
                dataIndex: 'Name'
            },
            {
                text: "Email",
                width: 380,
                dataIndex: 'Email'
            }
        ],
        renderTo: 'example-grid',
        width: 500,
        height: 280
    });
});
1
relation to php? - Funk Forty Niner
i'm loading data from mysql while ($row = mysqli_fetch_array($result)) { $myInventory["employees"][$counter] = array( 'Employee_ID' => $row['Employee_ID'], 'Department_ID' => $row['Department_ID'], 'Name' => $row['Name'], 'Email' => $row['Email']); $counter++; } $myData = $myInventory; echo json_encode($myData); ?> - George Sendrea
if this is a php/db related issue, edit your question stackoverflow.com/posts/44000454/edit with code and not be dropped in comments; thank you - Funk Forty Niner
i don't have problem with php i have problem with extjs - George Sendrea
the php tag has been removed. Only use tags that are related to the problem. In using tags not relevant to the problem, is both unclear and misleading. - Funk Forty Niner

1 Answers

3
votes

Try changing the store's proxy type from memory to ajax. Memory proxy usually is for data that will be loaded from the client session itself, not from a remote source.