Mir Gulam Sarwar
Mir Gulam Sarwar

Reputation: 2648

Grid showing empty rows extjs

Here, store loads data from databse(firebug shows) but all rows are empty...Please help.I cant find the reason behind...

Store

autoLoad: true,
model: 'CustomerService.model.OrderModel',
idProperty: 'id',
fields: [{
    name: 'id',
    type: 'int'
}, {
    name: 'name',
    type: 'string'
}, {
    name: 'quantity',
    type: 'int'
}, {
    name: 'receivedquantity',
    type: 'int'
}],
proxy: {
    type: 'ajax',
    url: 'data/Getall.php',
    reader: {
        type: 'json',
        root: 'data',
        successProperty: 'success'
    }
}
});

Here is Model:

Ext.define('CustomerService.model.OrderModel', {
    extend: 'Ext.data.Model'
});

here is view:

Ext.define('CustomerService.view.customer.List', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.mylist',
    selModel: Ext.create('Ext.selection.CheckboxModel', {
        checkOnly: false
    }),
    store: 'OrderStore',
    forceFit: true, //Fit to container:: columnLines:true, height:132, width:200, autoResizeColumns:true, initComponent:function(){

    this.columns = [{
        header: 'name',
        dataIndex: 'name'
    }, {
        header: 'Quantity',
        dataIndex: 'quantity',
    }, {
        header: 'Received Quantity',
        dataIndex: 'receivedquantity'
    }];
    this.callParent(arguments);
}
});

Upvotes: 1

Views: 3026

Answers (1)

CD..
CD..

Reputation: 74166

If your using a model in your store you should define the fields in your model instead of defining them in your store.

Ext.define('CustomerService.model.OrderModel', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int'
    }, {
        name: 'name',
        type: 'string'
    }, {
        name: 'quantity',
        type: 'int'
    }, {
        name: 'receivedquantity',
        type: 'int'
    }],
});

Ext.data.Store fileds:

This may be used in place of specifying a model configuration. The fields should be a set of Ext.data.Field configuration objects. The store will automatically create a Ext.data.Model with these fields. In general this configuration option should only be used for simple stores like a two-field store of ComboBox. For anything more complicated, such as specifying a particular id property or associations, a Ext.data.Model should be defined and specified for the model config.

Upvotes: 1

Related Questions