-
-
Save norbajunior/812628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var instrutor = function(json, record) { | |
var nome = ""; | |
record.instrutores.forEach(function(inst){ nome += (inst.nome + ", ") }); | |
return nome; | |
} | |
var CursoFactory = Ext.data.Record.create(["id", "nome", "descricao", | |
{name:"instrutores", convert: instrutor}]); | |
var store = new Ext.data.Store({ | |
url: "/cursos.json", | |
reader: new Ext.data.JsonReader({ | |
id: "id", root: "results", total: "total" | |
}, CursoFactory) | |
}) | |
store.load(); | |
var grid = new Ext.grid.GridPanel({ | |
store: store | |
, colModel: new Ext.grid.ColumnModel({ | |
columns: [ | |
{id:"id", header: "Id", width: 20, sortable: true, dataIndex: "id"} | |
, {header: "Nome", width: 200, sortable: true, dataIndex: "nome"} | |
, {header: "Descrição", width: 200, sortable: true, dataIndex: "descricao"} | |
, {header: "Instrutores", width: 200, sortable: true, dataIndex: "instrutores"} | |
] | |
}) | |
, sm: new Ext.grid.RowSelectionModel() | |
, title: "Cursos", width: 600, height: 300, frame: true | |
, listeners: { | |
rowdblclick : function( grid, rowIndex, event ) { | |
var json = grid.getSelectionModel().getSelected().json; | |
var win = new Ext.Window({ | |
modal:true, title: "Curso", width: 300, height: 200 | |
}); | |
win.show(); | |
} | |
} | |
, style: "margin: auto;" | |
}); | |
grid.render("treinamento"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment