PDA

View Full Version : cannot get value from columnmodel to pass parameter to a link



missgextjs
23 Jun 2010, 3:45 AM
Hello everyone,

I'm newbie of extjs - my problem is how can I get value data (club_id) from datastore or columnmodel when I click on <a href> link for pass parameter to php file.
My Code is
========

resultDataStore = new Ext.data.Store({
id: 'resultDataStore',
proxy: new Ext.data.HttpProxy({
url: 'clubstatus.php',
method: 'POST'
}),
baseParams:{
task: ""
},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'club_guid'
},[
{name: 'club_guid', type: 'int', mapping: 'club_guid'},
...
...
{name: 'sum_operator', type: 'int', mapping: 'sum_operator'},
]),
sortInfo:{field: 'club_guid', direction: "ASC"}
});
resultColumnModel = new Ext.grid.ColumnModel(
[
{
header: '<b>Club ID</b>',
id: 'p_club_guid',
readOnly: true,
dataIndex: 'club_guid',
width: 70,
sortable: true,
hidden: false,
readOnly: true
},

...
...
,
{
header: '<b>Total</b>',
readOnly: true,
dataIndex: 'sum_operator',
align: 'right',
width: 100,
sortable: true,
hidden: false,
readOnly: true,
renderer: function(value) {
return "<a href="test.php?club_guid=xxxx">"+value+"</a>" }
}


resultColumnModel.defaultSortable= true;
resultDataStore.load();
resultListingEditorGrid = new Ext.grid.EditorGridPanel({
id: 'resultListingEditorGrid',
store: resultDataStore,
cm: resultColumnModel,
enableColLock:false,
clicksToEdit:1,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
autoHeight: true,
align: 'center'
//height: 500,
});


resultListingEditorGrid.render('div_result');

Condor
23 Jun 2010, 3:53 AM
A renderer has more parameter (see the API docs for Ext.data.ColumnModel.setRenderer).

missgextjs
23 Jun 2010, 7:16 PM
Can you give me some example ? I'm really newbie :(

Condor
23 Jun 2010, 11:26 PM
Example:

renderer: function(value, meta, record) {
return "<a href="test.php?club_guid=' + record.get('club_guid') + '">" + value + "</a>";
}

ps. I a true single-page Web 2.0 application you wouldn't be using anchors. Instead you render the value as blue/underlined (so it looks like a link) and register a cellclick event handler on the grid.

missgextjs
24 Jun 2010, 11:47 PM
Many thanks for your kindly , Condor :)
I can continue coding huh huh .. ^^