簡體   English   中英

ExtJS的網格中未顯示兩個模型的屬性

[英]properties of two models are not shown in grid with ExtJS

我有兩個模型(Cliente和Pago),並在第三個模型(Modelo)中將它們放在一起,但是在鏈接數據以在網格中顯示它們時,我無法使其顯示我擁有的信息。兩個模型,如果有數據,返回我的方法的json。

如何呈現或顯示我的注冊數據?

模型模型

public class Modelo
{
    public Pagos Pagos { get;  set; }
    public Cliente Cliente { get;  set; }

    public Modelo()
    {
        Pagos = new Pagos();
        Cliente = new Cliente();
    }
}

模特客戶

public class Cliente
{
    public int IdCliente { get;  set; }
    public string Nombre { get;  set; }
    public int Comision { get;  set; }
    public int Estatus { get;  set; }
}

模型帕果

public class Pagos
{
    public int IdPago { get; set; }
    public int IdCliente { get; set; }
    public Decimal Monto { get; set; }
    public bool Autorizacion { get; set; }
    public string Comentario { get; set; }
    public DateTime Fecha { get; set; }
}

我已經嘗試放置model.property但是它不起作用。

在此處輸入圖片說明

Ext.define('Modelo', {
    extend: 'Ext.data.Model',
    proxy: {
        type: 'ajax',
        reader: 'Home/GetPagosAutorizados'
    },
    fields: [
        { name: 'IdPago', type:'int' },
        { name: 'Cliente', type: 'string' },
        { name: 'Monto', type: 'float' },
        { name: 'Comision', type: 'int' },
        { name: 'Autorizacion', type: 'bool' },
        { name: 'Comentario', type: 'string' },
        { name: 'Fecha', type: 'string' }
    ]
});
    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
        model: 'Modelo.Pagos',
        proxy: {
            pageParam: false, //to remove param "page"
            startParam: false, //to remove param "start"
            limitParam: false, //to remove param "limit"
            noCache: false, //to remove param "_dc"
            //storeId: 'Data',
            // load using HTTP
            type: 'ajax',
            url: 'Home/GetPagosAutorizados',
            // the return will be XML, so lets set up a reader
            reader: {
                type: 'json',
                rootProperty: 'data'
            }
        }
    });


    // create the grid
    var grid = Ext.create('Ext.grid.Panel', {        
        bufferedRenderer: false,
        store: store,
        columns: [
            { text: "ID Pago", width: 120, dataIndex: 'Pagos.IdPago', sortable: true },
            { text: "Cliente", flex: 1, dataIndex: 'Cliente.Nombre', sortable: true },
            { text: "Monto", width: 125, dataIndex: 'Monto', sortable: true },
            { text: "Comisión", width: 125, dataIndex: 'Comision', sortable: true },
            { text: "Autorización", width: 125, dataIndex: 'Autorizacion', sortable: true },
            { text: "Comentario", width: 125, dataIndex: 'Comentario', sortable: true },
            { text: "Fecha", width: 125, dataIndex: 'Fecha:date', sortable: true }
        ],
        forceFit: true,
        height: 210,
        split: true,
        region: 'north'
    });
Ext.define('Modelo', {
    extend: 'Ext.data.Model',
    proxy: {
        type: 'ajax',
        reader: 'Home/GetPagosAutorizados'
    },
    fields: [
        // set up the fields mapping into the xml doc
        // The first needs mapping, the others are very basic
        //{ name: 'Author', mapping: '@author.name' },
        { name: 'IdPago', type: 'int', mapping: 'Pagos.IdPago' }, 
        { name: 'Nombre', type: 'string', mapping: 'Cliente.Nombre' },
        { name: 'Monto', type: 'float', mapping: 'Pagos.Monto' },
        { name: 'Comision', type: 'int', mapping: 'Cliente.Comision' },
        { name: 'Autorizacion', type: 'bool', mapping: 'Pagos.Autorizacion' },
        { name: 'Comentario', type: 'string', mapping: 'Pagos.Comentario' },
        { name: 'Fecha', type: 'string', mapping: 'Pagos.Fecha' }
    ]
});


var grid = Ext.create('Ext.grid.Panel', {        
    bufferedRenderer: false,
    store: store,
    columns: [
        { text: "ID Pago", width: 120, dataIndex: 'IdPago', sortable: true },
        { text: "Nombre", width: 120, dataIndex: 'Nombre', sortable: true },
        { text: "Monto", width: 125, dataIndex: 'Monto', sortable: true },
        { text: "Comision", width: 125, dataIndex: 'Comision', sortable: true },
        { text: "Autorización", width: 125, dataIndex: 'Autorizacion', sortable: true },
        { text: "Comentario", width: 125, dataIndex: 'Comentario', sortable: true },
        { text: 'Fecha', dataIndex: 'Fecha'  }
    ],
    //forceFit: true,
    height: 210,
    //split: true,
    region: 'north'
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM