PDA

View Full Version : getting adjacent column value to build a link in grid getting previous row value



shankar8rajah1
24 Oct 2013, 8:30 AM
I have this column definition:


var createHeaders = function (finish, start) {

var columns = [{
dataIndex: 'name',
text: 'Name',
renderer: function renderIcon(val) {
return '<a href="' + val + ait_val+ '">' + val +'</a>';
}

}, {
dataIndex: 'service_group',
text: 'Service Group',

}, {
dataIndex: 'azul_zvm_version',
text: 'Azul ZVM Version',

}, {
dataIndex: 'azul_zst_version',
text: 'Azul ZST Version',

}, {
dataIndex: 'host_tech',
text: 'Host Tech',
renderer: function renderIcon(val) {
return '<a href="' + val + '">' + val +'</a>';
}

}, {
dataIndex: 'ait_num',
text: 'AIT Num',
renderer: function renderIcon(val) {
ait_val = val
return '<a href="' + val + '">' + val +'</a>';
}

}, {
dataIndex: 'app_name',
text: 'App Name',
renderer: function renderIcon(val) {
return '<a href="' + val + '">' + val +'</a>';
}

},{
dataIndex: 'data_center',
text: 'Data Center',

},{
dataIndex: 'instances',
text: 'Instances',

},{
dataIndex: 'env',
text: 'Env',

}];


return columns.slice(start || 0, finish);
};

In the name column, I need to build a link that uses the ait column value for each respective row, however, the way I have it right now, it is getting the ait value of the previous row.

For example:

Name | AIT
x | 1
y | 2
z | 3

For y, the link is y + 1 instead of y + 2.

Scott-1
24 Oct 2013, 9:36 AM
Try using the record directly, below is my example of a calculated field. The fact that you are overriding the rendering and also data binding my have some confusion.

{itemId: 'percentOfExpectedSales', text: "% of Expected Sales", width: 120, sortable: true,
renderer : function(value, metaData, record, rowIdx, colIdx, store, view){
var expectedSales = record.get('expectedSales');
var deposits = record.get('deposits');
if (expectedSales < 0 || deposits < 0){
return '%';
}
return Math.floor((deposits / expectedSales) * 100).toString() + '%';
},

shankar8rajah1
25 Oct 2013, 5:11 AM
That worked, thanks!

On quick tangent, as I am fairly new to all this, I am getting a double quotes around the ait_num value in the link.

For example:

www.something.com/?ait_num="5122"

I tried doing a substring to ignore the 1st and last letter, but that gave me back 12, as if the quotes wasn't part of the value. Would you know how to get rid of the quotes or why it's there in the first place when I get the record value?

Scott-1
25 Oct 2013, 5:57 AM
That is a basic javascript substring function, not related to ExtJS so you should be able to debug that through the IE, FireFox or Chrome debugger.

My first guess is make sure the data is clean. The concatenation appears correct.

shankar8rajah1
25 Oct 2013, 11:59 AM
figured it out, thanks for your quick reply!