Child row: adding a condition on some column
Child row: adding a condition on some column
Pandalex
Posts: 32Questions: 8Answers: 1
Hi everyone,
I'm displaying my child row without any issue.
But no I can access my jsp through 2 pages.
I would like to display columns depending on the origin.
I have the information in a session variable :
var site = '${sessionScope.site}';
I want to add a test but it seems to be impossible to do that in the return of the format function:
function format ( d ) {
// `d` is the original data object for the row
return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Field one:</td>'+
'<td>'+d.fieldOne+'</td>'+
'</tr>'+
'<tr>'+
'<td>Field two:</td>'+
'<td>'+d.fieldTwo+'</td>'+
'</tr>'+
'<tr>'+
'<td>Field three:</td>'+
'<td>'+d.fieldThree+'</td>'+
'</tr>'+
if(site == 'T' )
{
'<tr>'+
'<td>Conditional field :</td>'+
'<td>'+d.conditionalField+'</td>'+
'</tr>'+
}
'</table>';
}
How should can I do this ?
Thx a lot
This question has an accepted answers - jump to answer
Answers
Create an if condition that builds the HTML string then the return statement can retun the string, for example:
Kevin
Thx it's perfect, I was wondering if I had to declare a type and what to return
Just return a string that contains properly formatted HTML.
Kevin