Witam.
Mam problem z ExtJS. Chciałbym połączyć datagrid z jsonem, ale coś mi nie idzie. Nie sypie błędami, pokazuje tylko nagłówek tabeli. Jest request po dane, w readerze one siedzą prawidłowo, ale nie wyświetla :[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="js/ext-base.js"> <script type="text/javascript" src="js/ext-all.js"> <link rel="stylesheet" href="css/ext-all.css"> <link rel="stylesheet" href="css/xtheme-gray.css"> <div id="content" style="width: 1024px; height: 768px;"> <script type="text/javascript"> var grid;
var ds;
Ext.onReady(function(){
init_grid();
});
function init_grid(){
ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'admin/ajax.php?get=users',
method: 'GET'
}),
reader: new Ext.data.JsonReader({
root: 'users',
totalProperty: 'total',
id: 'id'
}, ['id', 'login', 'email','registerDate']),
remoteSort: true
});
var cm = new Ext.grid.ColumnModel([{
id: 'id',
header: "ID",
dataIndex: 'id',
width: 250
}, {
header: "Login",
dataIndex: 'login',
width: 75
}, {
header: "E-mail",
dataIndex: 'email',
width: 75
}, {
header: "Register Date",
dataIndex: 'registerDate',
width: 100
}]);
cm.defaultSortable = true;
grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
autoExpandColumn: 'id'
});
grid.render('content');
ds.load();
}
a tak wygląda json
{"total":2,"users":[{"id":1,"login":"pawel","email":"pawel@ncreations.pl","registerDate":"2008-03-11 06:48:11"},{"id":2,"login":"micha\u0142","email":"michal@wp.pl","registerDate":"2008-03-11 06:48:11"}]}
Pozdrawiam,
Paweł
rozwiązane.... wystarczyło zrobić
grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
autoHeight: true, // tutaj była zmiana
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
autoExpandColumn: 'id'
});