Hoping someone can tell me if I'm going about this wrong, but I'm executing a QueryTask / Query on a map service and getting back a FeatureSet as expected. Within the attributes of each Graphic, I have two fields that are of type esriFieldTypeDate and their values are the long integer value representing the date. My problem is I'm not seeing it formatted in any way when it's displayed in my dynamically created DataGridColumn. I'd like to see it in MM/DD/YYYY format.
I was hoping to check the attribute's data type and if it was equal to 'esriFieldTypeDate' - run some formatting / conversion method on it. But, I can't even get the data type of the attribute. There is no spatial querying going on here, this is purely based on attribute data entered on a form in the application.
The last if statement of the sample below is an error - just showing my thought process. Also, the "resultFields" variable is an array of field names. I use that to allow the field order to configurable.
Should I not be using a QueryTask for this???
function onResult(featureSet:FeatureSet, token:Object = null):void
{
...
for each (var gr:Graphic in featureSet.features)
{
for (var i:int = 0; i < resultFields.length; i++)
{
var hg:HGroup = new HGroup();
var lab:Label = new Label();
lab.width = 200;
var dgc:DataGridColumn = resultFields[i] as DataGridColumn;
lab.text = dgc.headerText + ": ";
hg.addElement(lab);
var valLabel:Label = new Label();
if (gr.attributes[dgc.dataField].type != "esriFieldTypeDate")
{
//Not a date - display text value
valLabel.text = gr.attributes[dgc.dataField].type;
}
else
{
//Attribute is a date - format it to MM/DD/YYYY
valLabel.text = gr.attributes[dgc.dataField];
}
// ... add value label to group, add group to column, add column to grid etc.