PDA

View Full Version : grid function problem



Sako
17 Jan 2010, 8:49 AM
Hi,
this code does not work and I don't know why.../:)


Ext.onReady(function() {
Ext.QuickTips.init();
var xg = Ext.grid;


...

var store = new Ext.data.GroupingStore({
url: 'B_remote-plex.php',
sortInfo: {
field: 'genre',
direction: "ASC"
},
totalProperty: 'count',
groupField: 'genre',
reader: new Ext.data.JsonReader({
root:'listings',
id:'id'
}, [
'id',
'genre',
'adress',
'chamber',
'sdb',
{name: 'prix', type: 'int'},
'img',
'region',
{name: 'lat', type: 'float'},
{name: 'lng', type: 'float'},
'icons',
'code'
])
});

store.load();

var genres = new Ext.data.SimpleStore({
fields: ['id', 'genre'],
data : [['2','Duplex'],['3','Triplex'],['4','Quadruplex'],['5','Quintuplex'],['6','Sixplex'],['7','Multilogement']]
});


var grid = new xg.GridPanel({
frame:true,
title: 'listings',
height:500,
width:328,
loadMask: true,
collapsible: true,
animCollapse: true,
enableHdMenu : false,
enableColumnMove : false,
store: store,
autoExpandColumn: 'descrip',
columns: [

...

{ header: "", width: 35, dataIndex: 'icons',sortable: true, hidden: false, renderer: function(w){return '<A onclick="test();"><img src="icons/' + w + '" width="20" height="23" align="left"/></A>'; }}
],

sm: new Ext.grid.RowSelectionModel({
singleSelect: true}),

view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text} ({[values.rs.length]})'
})

});

grid.render('sidebar');


function test(){
alert("test");
}


});
never the alert appear I am missing something?

regards

17 Jan 2010, 10:47 AM
the event cascade is probably being killed by the column model or grid view.

17 Jan 2010, 10:47 AM
btw, you should consider not using onclick.

Sako
17 Jan 2010, 11:27 AM
ok thank you!

As you suggested...this code works well:


return '<A href="javascript:test()"><img src="icons/' + w + '" width="20" height="23" align="left"/></A>';