You can define the content for the info window or popup by providing a function that can calculate the value. The 'Format info window content' help topic has details on the various options. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/intro_formatinfowindow.htmHere's an example of how you can use a custom formatting function to determine if a field is null. If its not null you can display a value and if null you can display different text. This code snippet defines an info template with a custom formatting function called calculateDeaths that determines if the Num_Deaths field has a value.
var infoTemplate = new esri.InfoTemplate("${Name}");
infoTemplate.setTitle("${Name}");
infoTemplate.setContent("Magnitude ${Magnitude:NumberFormat(round:2)} earthquake occurred on ${Date_:DateFormat(datePattern:'MMMM d, yyyy.', selector:'date')}<br/>Deaths: ${Num_Deaths:calculateDeaths}" );
Here's what the function looks like:
function calculateDeaths(value,key,data){
return data.Num_Deaths !== null ? data.Num_Deaths : 'No Deaths';
}
Alternatively you can use a function to define the entire window's content so if you like you can not display null values. Here's a code snippet showing how you can define an info template that uses a function to display content: var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle("${Name}");
infoTemplate.setContent(getContent);
And here's the function that defines the content:
function getContent(graphic){
var numInjured = graphic.attributes.Num_Injured;
var numDeaths = graphic.attributes.Num_Deaths !== null ? graphic.attributes.Num_Deaths : 'No Deaths';
var content = "<b>Magnitude: </b>" + graphic.attributes.Magnitude + "<br/><b>Deaths: </b> " + numDeaths ;
if(numInjured !== null){
content += "<br/><b>Injured: </b>" + numInjured;
}
return content;
}