How to Make a Lookup Table or Dictionary in DataHub WebView
This example shows how to create a Lookup Table or Dictionary in the DataHub WebView. This will allow you to display a text string depending on the value coming from a tag.
- On the Page, there is an
OnPageLoadStartedevent. In the event, you want to copy and paste the following text:nameLookupTable = new Dictionary<|int,string|>();
nameLookupTable.Add(1, "one");
nameLookupTable.Add(2, "two");
nameLookupTable.Add(3, "three");
nameLookupTable.Add(4, "four");
nameLookupTable.Add(5, "five");
nameLookupTable.Add(6, "six");
function lookupName(value, lut)
{
var result = "none";
try
{
result = lut[value];
}
catch (e)
{
/* result = e.Message; */
}
return result;
} - Replace the "one", "two", etc with the text you want to display.
- Replace the 1, 2, etc with the tag values that correspond with the string values you just edited.
- Add a label to your page. Set the Binding to Script and use the following script:
lookupName(VAL("default:test"), nameLookupTable); - Replace the "default:test" with your tag name that holds the values from step 3