PDA

View Full Version : GroupingStore + JsonReader + GridPanel = two error



cybermerlin
3 Jan 2011, 3:20 PM
i have two truble. :(
1) needed ';' in searchCert.php?limit=10&_dc=1294074135572&callback=stcCallback1001, line 1 position 15
-- this bug see if i start load page whit grid panel
on "data: [" -- position 15 ==> ":"

2) 'this.fields.get(...).sortType' - this is null or not object ext-all.js, line 7 position 318034
-- this bug of a complete Ajax response on storeCert.loadData(jsR.data); line

seerver response:

{rows:20, data: [{id:1,FullName:'Древин Андрей Валерьевич',Depart:'Администратор АРМ',Company:'ЗАО Удостоверяющий центр',Status:'Просрочен',CA:'NWUDCCA1SUB1',SN:'61647C0F000000000006',ExprDate:'2006-02-10'},{id:2,FullName:'Древин Андрей Валерьевич',Depart:'Оператор АРМ',Company:'ЗАО Удостоверяющий центр',Status:'Просрочен',CA:'NWUDCCA1SUB1',SN:'6164DAB9000000000007',ExprDate:'2006-02-10'}]}


winSearch = new Ext.Window({
title: 'Посик отзываемых сертификатов...',
width: 500,
autoDestroy:false,
//autoScroll:true,
maximizable: true,
closeAction: 'hide',
autoHeight: true,
minWidth: 300,
minHeight: 200,
layout: 'fit',
//plain:true,
bodyStyle:'padding:5px;',
buttonAlign:'center',
items: form,

buttons: [{
text: 'поиск',
handler: function() {
if (form.form.isValid()) {
Ext.Ajax.request({
loadMask: true,
url : 'searchCert.php',
method: 'POST',
params : { limit : 20 },
maskEl : winSearch,
loadingMessage : 'Выполняется запрос...',
success : function(response) {
if (response.is_success) {
Ext.Msg.alert('Сохранение', 'Сохранение прошло успешно!');
var jsR = Ext.util.JSON.decode(response.responseText);
alert(jsR.data[1].FullName);
storeCert.loadData(jsR.data);
}
}
});
}
}
},{
text: 'отмена',
handler:function(){winSearch.hide();}
},{
text : 'сброс',
handler: function() {
form.form.reset();
}
}]
});


storeCert = new Ext.data.GroupingStore({
proxy: new Ext.data.ScriptTagProxy({
url: '<? echo SITE; ?>searchCert.php',
method: 'POST'
}),
reader: new Ext.data.JsonReader({
//root: 'data',
totalProperty: 'rows',
id: 'id',
remoteGroup:true,//-----
remoteSort: true,//-----
//idProperty:'company',
fields: [
{name: 'fullname', type: 'string', mapping:'FullName',sortType:Ext.data.SortTypes.asUCString},
{name: 'company', type: 'string', mapping:'Company',sortType:Ext.data.SortTypes.asUCString},
{name: 'depart', type: 'string', mapping: 'Depart',sortType:Ext.data.SortTypes.asUCString},
{name: 'status', type: 'string', mapping:'Status',sortType:Ext.data.SortTypes.asUCString},
{name: 'ca', type: 'string', mapping:'CA',sortType:Ext.data.SortTypes.asUCString},
{name: 'sn', type: 'string', mapping:'SN',sortType:Ext.data.SortTypes.asUCString},
{name: 'exprdate', type: 'date', dateFormat:'m/d/Y', mapping:'ExprDate',sortType:Ext.data.SortTypes.asDate}//,
//{name: 'pkcs', type: 'string', mapping:'PKCS'}
]
},
Ext.data.Record.create([
{name:'fullname', mapping: 'FullName'}
])
),

baseParams: {limit:10},
sortInfo: {field: 'sn', direction: 'ASC'},
groupField: 'exprdate'
});
storeCert.load({params:{limit:10}});

var grid = new Ext.grid.GridPanel({
renderTo: 'example-grid',

store: storeCert,

columns: [
{ id: 'fullname', header: 'Фамилия Имя Отчество<br/>&nbsp;', width: 80, sortable: true, dataIndex: 'fullname', hideable: true },
{ header: 'организация<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'company', hideable: true },
{ header: 'отделение<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'depart', hideable: true },
{ header: 'статус<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'status', hideable: true },
{ header: 'УЦ<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'ca', hideable: true },
{ header: 'серийный<br/>номер&nbsp;', width: 20, sortable: true, dataIndex: 'sn', hideable: true },
{ header: 'валиден<br/>до', width: 25, sortable: true, dataIndex: 'exprdate', renderer: Ext.util.Format.dateRenderer('m/d/Y'), hideable: true }//,
//{ header: 'тело<br/>&nbsp;', width: 20, sortable: false, dataIndex: 'pkcs', hideable: true }
],

view: new Ext.grid.GroupingView({
forceFit:true,
//showGroupName: false,
//enableNoGroups:false,
//enableGroupingMenu:false,
//hideGroupedColumn: true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "элементов" : "элемент"]})'
}),

tbar : [{
text: 'Поиск...',
tooltip: 'Поиск сертификатов...',
handler: function(){winSearch.show();}
}],

/*bbar: new Ext.PagingToolbar({
store: reader,
pageSize: 20,
displayInfo: true,
displayMsg: '{0} - {1} из {2}',
emptyMsg: "больше нет данных"
}),*/

fbar : ['->', {
text:'Без группировки',
iconCls: 'icon-clear-group',
handler : function(){
storeCert.clearGrouping();
}
}],

frame: true,
//width: 800,
height: 450,
//clicksToEdit: 2,
collapsible: true,
animCollapse: true,
trackMouseOver: false,
//enableColumnMove: false,
title: 'Сертификаты клиентов...',
iconCls: 'icon-grid'
});

//grid.store.load();
});
(:|:s

cybermerlin
4 Jan 2011, 7:32 AM
Help somebody?

cybermerlin
5 Jan 2011, 11:24 AM
I have corrected my json

{"rows":20, "data": [{"id":1,"FullName":"Древин Андрей Валерьевич","Depart":"Администратор АРМ","Company":"ЗАО Удостоверяющий центр","Status":"Просрочен","CA":"NWUDCCA1SUB1","SN":"61647C0F000000000006","ExprDate":"2006-02-10"},{"id":2,"FullName":"Древин Андрей Валерьевич","Depart":"Оператор АРМ","Company":"ЗАО Удостоверяющий центр","Status":"Просрочен","CA":"NWUDCCA1SUB1","SN":"6164DAB9000000000007","ExprDate":"2006-02-10"}]}
but truble not hide (

cybermerlin
7 Jan 2011, 5:40 PM
up.. for help

cybermerlin
10 Jan 2011, 1:16 AM
changed js

Ext.onReady(function(){

Ext.QuickTips.init();



// utilize custom extension for Hybrid Summary

grid = new Ext.grid.GridPanel({
ds: new Ext.data.GroupingStore({
//autoLoad: true,
url: 'http://192.168.188.129/crl_udc/totals-hybrid.php',
reader: new Ext.data.JsonReader(
{root:'data'},
[
{name: 'fullname', type: 'string', mapping:'FullName',sortType:Ext.data.SortTypes.asUCString},
{name: 'company', type: 'string', mapping:'Company',sortType:Ext.data.SortTypes.asUCString},
{name: 'depart', type: 'string', mapping: 'Depart',sortType:Ext.data.SortTypes.asUCString},
{name: 'status', type: 'string', mapping:'Status',sortType:Ext.data.SortTypes.asUCString},
{name: 'ca', type: 'string', mapping:'CA',sortType:Ext.data.SortTypes.asUCString},
{name: 'sn', type: 'string', mapping:'SN',sortType:Ext.data.SortTypes.asUCString},
{name: 'exprdate', type: 'date', dateFormat:'m/d/Y', mapping:'ExprDate',sortType:Ext.data.SortTypes.asDate}
]),
idProperty: 'fullname',
sortInfo: {field: 'fullname', direction: 'ASC'},
groupField: 'company'
}),

columns: [
{ id: 'fullname', header: 'Фамилия Имя Отчество<br/>&nbsp;', width: 80, sortable: true, dataIndex: 'fullname', hideable: true },
{ header: 'организация<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'company', hideable: true },
{ header: 'отделение<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'depart', hideable: true },
{ header: 'статус<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'status', hideable: true },
{ header: 'УЦ<br/>&nbsp;', width: 20, sortable: true, dataIndex: 'ca', hideable: true },
{ header: 'серийный<br/>номер&nbsp;', width: 20, sortable: true, dataIndex: 'sn', hideable: true },
{ header: 'валиден<br/>до', width: 25, sortable: true, dataIndex: 'exprdate', renderer: Ext.util.Format.dateRenderer('m/d/Y'), hideable: true }
],

view: new Ext.grid.GroupingView({
forceFit:true,
showGroupName: false,
//enableNoGroups:false,
hideGroupedColumn: true,
groupOnSort: true//,
//groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Rechnungen" : "Rechnung"]})'
}),

frame: true,
width: 800,
height: 450,
clicksToEdit: 1,
collapsible: true,
animCollapse: false,
trackMouseOver: false,
//enableColumnMove: false,
title: 'Sponsored Projects',
iconCls: 'icon-grid',
renderTo: document.body
});


// load the remote data
grid.store.load();

});

i see my data
console.log(grid.store.reader.jsonData.root[1]);
but grid has no rows