I want to create a certain function to streamline some of my customization work.I work with a web app that's built using ArcGIS JavaScript API which contains a few layers.Each layer is configured to an identity task that uses a popup template to display attribute information from the layer.Now, there are lots of attributes PER layer that I manually configure up in the popup template declaration.Ex.
var popupContent = {
title: "Business ID#: {UNIQUEID_1}",
fieldInfos: [
{fieldName: "BUSNAME_1", visible: true, label:"Business Name: "},
{fieldName: "Standard_Name", visible: true, label:"Standard Name: "},
{fieldName: "LATITUDE_1", visible: true, label:"Latitude: "},
{fieldName: "LONGITUDE_1", visible: true, label:"Longitude: "},
{fieldName: "INFO_EMP_1", visible: true, label:"Employment Info: "},
{fieldName: "Est_Employment", visible: true, label:"Estimated Employment: "},
{fieldName: "INFO_SAL_1", visible: true, label:"Salary Info: "},
{fieldName: "Est_Revenue", visible: true, label:"Estimated Revenue: "},
{fieldName: "PRMSIC4_1", visible: true, label:"Primary SIC: "},
{fieldName: "NAICS_1", visible: true, label:"NAICS: "},
{fieldName: "NAICS4_1", visible: true, label:"NAICS 4 Code: "},
{fieldName: "NAICS4DESC_1", visible: true, label:"NAICS 4 Desc.: "},
{fieldName: "NAICS2_1", visible: true, label:"NAICS 2 Code: "},
{fieldName: "NAICS2DESC_1", visible: true, label:"NAICS 2 Desc.: "},
{fieldName: "Use_Type", visible: true, label:"Use Type: "},
{fieldName: "UseSubcategory", visible: true, label:"Use Subcategory: "},
{fieldName: "UseCategory", visible: true, label:"Use Category: "}
]
};
This is one of the shorter templates that i use, but as you can see, it gets pretty tedious to set these manually. Once in a while is okay, but the layers are constantly getting fields added/removed. I was wondering if any of you had any clever ideas as to how I could automate this.One possible way I was thinking is to have a table in my ArcGIS server that acts as a lookup table for the fields.Table structure: 1. The column field names in this table will be the "Layername_fieldname" and "LayerName_label" of the layers in my web app (from the layers' corresponding attribute tables).Ex. || Layer1_fieldname || Layer1_label || Layer2_fieldname || Layer2_label ||
--------------------------------------------------------------------------
|| BusinessLoc || Biz Location:|| CountyBoundary || County Name: ||
|| || || || ||
2. Rows can be added or deleted as needed to each column as my web app layers grow or shrink in attribute size.Basically, I want to know if this is a viable option or if there are other methods out there to perform this task. If this is a good solution, is it possible to query the field lookup table and use those values in my popup template constructor. Any help or ideas would be greatly appreciated.Thanks!