PDA

View Full Version : New tab with ajax and renderer



Mycoding
30 Jun 2010, 8:57 AM
Please, give me a hint how to do like this.
The user press button add new tab(I did), and in new tab to be loading json data that formed perphaps in renderer.
At the moment I have this
21197
Code is


bbar: [{
id:'toolbarButtonPrivateCabinet',
text:'?????? ???????',
handler:function(){
var store = new Ext.data.Store({
url: 'http://vreshenie.ru/usertest.json',
reader: new Ext.data.JsonReader({root:'rows',id:'id'}, ['id','email','firstVisit','prevVisit','ip','dataOfUserSystem','id','money','thisMonthPaid','allMonthPaid','rateNPlus','rateNMinus'])
});
function user_renderer(val, x, store){
return 'Email:<h1>'+store.data.email+'</h1>'+
'?????? ?????????:<p>'+store.data.firstVisit+'</p>'+
'??????? ????????? ?????????:<p>'+store.data.prevVisit+'</p>'+
'IP ??? ?????? ?????????:<p>'+store.data.ip+'</p>'+
'????? ?? ?????:<p>'+store.data.money+'</p>'+
'???????? ?? ?????:<p>'+store.data.thisMonthPaid+'</p>'+
'??? ???????????? ??????:<p>'+store.data.thisMonthPaid+'</p>'+
'??????? ??????+:<p>'+store.data.rateNPlus+'</p>'+
'??????? ??????-:<p>'+store.data.rateNMinus+'</p>'+
'<b style="font-size: 13px;"><p>?????? ? ??????? ??? ?????? ?????????'+store.data.dataOfUserSystem+'</p></b>';
}
store.load();
Ext.getCmp('center').add({
title:'?????? ???????',
iconCls:'smallImageUser',
closable:true,
store:store,
renderer:user_renderer}).show();
},
hidden:true
},{

Mycoding
1 Jul 2010, 10:11 PM
It works now



bbar: [{
id:'toolbarButtonPrivateCabinet',
text:'?????? ???????',
handler:function(){
Ext.Ajax.request({
url: 'http://vreshenie.ru/usertest-1.json',
waitMsg: '????????...',
success: function(result, request){
jsonData = Ext.util.JSON.decode(result.responseText);
//alert(result.responseText);
//var data = eval('('+result.responseText+')');
//alert(data.email);
//alert(jsonData.rows[0].email);
if(jsonData.success!=true){Ext.Msg.alert('????? ???????','?????? ?? ????????.');}
else{
var data=jsonData.rows[0],
html='Email:'+data.email+
'<br>?????? ?????????:'+data.firstVisit+
'<br>??????? ????????? ?????????:'+data.prevVisit+
'<br>IP ??? ?????? ?????????:'+data.ip+
'<br>????? ?? ?????:'+data.money+''+
'<br>???????? ?? ?????:'+data.thisMonthPaid+
'<br>??? ???????????? ??????:'+data.thisMonthPaid+
'<br>??????? ??????+:<p>'+data.rateNPlus+
'<br>??????? ??????-:<p>'+data.rateNMinus+
'<br>?????? ? ??????? ??? ?????? ?????????'+data.dataOfUserSystem;
Ext.getCmp('center').add({title:'?????? ???????',iconCls:'smallImageUser',closable:true,autoScroll:true,padding:'5 5 5 5',html:html}).show();
}
}
});
},
hidden:true
},{

4 Jul 2010, 8:35 AM
why not have the back-end return the formatted HTML instead of making the client do all of that work needlessly?