brondsem
01-26-2007, 10:11 AM
If you want one column in your grid to contain a link to a detail page for that entry, you can do something like this:
var me = this; // 'this' is a special variable, so we use 'me' to maintain a reference to it
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Student", width: 125, renderer: function(value, row, column, node) {
// me.grids[divId] is how I reference my grid from my GridManager class, yours will probably vary
return '' + value + ' (detail.php?id=' + me.grids[divId].dataModel.getRowId(row) + ')';
} },
{header: "First Choice", width: 100},
{header: "Second Choice", width: 100},
...
This uses the ID from your datamodel. My JSON dataModel declares the ID like this:
var dataModel = new YAHOO.ext.grid.JSONDataModel({
root: 'Results',
id: 'form_id',
fields: ['name', 'requestedBuilding1', 'requestedBuilding2', ...]
});
You'll probably want this in your CSS, too:
.ygrid-row-selected a:link, .ygrid-row-selected a:visited {
color: white;
}
var me = this; // 'this' is a special variable, so we use 'me' to maintain a reference to it
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Student", width: 125, renderer: function(value, row, column, node) {
// me.grids[divId] is how I reference my grid from my GridManager class, yours will probably vary
return '' + value + ' (detail.php?id=' + me.grids[divId].dataModel.getRowId(row) + ')';
} },
{header: "First Choice", width: 100},
{header: "Second Choice", width: 100},
...
This uses the ID from your datamodel. My JSON dataModel declares the ID like this:
var dataModel = new YAHOO.ext.grid.JSONDataModel({
root: 'Results',
id: 'form_id',
fields: ['name', 'requestedBuilding1', 'requestedBuilding2', ...]
});
You'll probably want this in your CSS, too:
.ygrid-row-selected a:link, .ygrid-row-selected a:visited {
color: white;
}