Dashboard - XML List with searchability

Hello,

I have an event coming up that I need my graphic operator a quick way to search for lower 3rds. The list will have about 200 names on it, and I need the graphic operator to be able to search for the graphic by tying in name and having it auto fill based on the database. I know that this would be best done on Dashboard rather than XPression, but I have no idea how to do this, as I have limited programing skill. Is there something that is already created that I can use a start point? Any help on this would be great!

Hi Tom

Where is the list of names coming from? Are they input into the system manually or are you trying to pull them from somewhere?

James,

The list of name will come from excel and I was planning on converting it into an xml file so that Dashboard can read it.

There are several ways to solve this. One option would be to use a dropdown list constraint - these already automatically have an autocomplete capability in DashBoard:

Arthur A. Aaronson Buford B. Buckthorn Carl C. Carlson Dianna D. Dickenson Erica E. Ellis var newConstraint = params.createIntChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) { //for testing, I am replacing the file XML with hard-coded XML. Remove these lines for loading an actual file file = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' + '\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ''

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“item”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var takeID = parseInt(node.getAttribute(“takeid”));
var name = node.getAttribute(“name”);
constraintData.push({“key”: takeID, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createIntChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

ogscript.rename('selected-take', this.getValue()); loadData('data.xml');

You can also provide the dropdown list as a search field and show your whole table:

Arthur A. Aaronson Buford B. Buckthorn Carl C. Carlson Dianna D. Dickenson Erica E. Ellis Arthur A. Aaronson Buford B. Buckthorn Carl C. Carlson Dianna D. Dickenson Erica E. Ellis all-take-ids all-names var newConstraint = params.createIntChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) { //for testing, I am replacing the file XML with hard-coded XML. Remove these lines for loading an actual file file = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' + '\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ''

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“item”); //Get the tags we want to include in the constraint

var allTakeIDs = ;
var allNames = ;
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var takeID = parseInt(node.getAttribute(“takeid”));
var name = node.getAttribute(“name”);
constraintData.push({“key”: takeID, “value”: name}); //Push the key/value pair
allTakeIDs.push(takeID);
allNames.push(name);
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
allTakeIDs.push(0);
allNames.push(‘’);
}

var constraint = params.createIntChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
params.setAllValues(‘all-take-ids’, allTakeIDs);
params.setAllValues(‘all-names’, allNames);
}

var index = this.getConstraint().getChoice(this.getValue()); params.setValue('table', 0, index); loadData('data.xml'); 40

Lastly, you could do a search box that looks for a full or partial match as the user types:

Arthur A. Aaronson Buford B. Buckthorn Carl C. Carlson Dianna D. Dickenson Erica E. Ellis all-take-ids all-names function getXML(file) { //for testing, I am replacing the file XML with hard-coded XML. Remove these lines for loading an actual file file = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' + '\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ''

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“item”); //Get the tags we want to include in the constraint

var allTakeIDs = ;
var allNames = ;

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var takeID = parseInt(node.getAttribute(“takeid”));
var name = node.getAttribute(“name”);
allTakeIDs.push(takeID);
allNames.push(name);
}

if (allNames.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
allTakeIDs.push(0);
allNames.push(‘’);
}

params.setAllValues(‘all-take-ids’, allTakeIDs);
params.setAllValues(‘all-names’, allNames);
}

function search(partial)
{
partial = partial.toLowerCase();
var allNames = params.getAllValues(‘all-names’);

//LOOK FOR AN EXACT MATCH
for (var i = 0; i < allNames.length; i++)
{
if (partial == allNames[i].toLowerCase())
{
return i;
}
}

//LOOK FOR AN “STARTS WITH” MATCH
for (var i = 0; i < allNames.length; i++)
{
if (allNames[i].toLowerCase().indexOf(partial) == 0)
{
return i;
}
}

//LOOK FOR AN “ANYWHERE” MATCH
for (var i = 0; i < allNames.length; i++)
{
if (allNames[i].toLowerCase().indexOf(partial) >= 0)
{
return i;
}
}

return -1;
}

function findName(partial)
{
var selectedIndex = search(partial);
params.setValue(‘table’, 0, selectedIndex);
}

function clearSearch()
{
params.setValue(‘search’, 0, ‘’);
}

true if (this.getValue() != '') { findName(this.getValue()); } loadData('data.xml'); 40

James,

Theses examples are great and exactly what I am looking for. I plan on trying to add an xml file to these tomorrow. Two questions, could you provide me an example xml file that would work with these? Also, the names will also need a second field associated with the names for titles. Will this be hard to do?

Hopefully once you look at the pattern, it will be fairly straight forward. To add additional attributes, you would simply add a new array parameter to hold the data and update the constraint of the table parameter to include it.

The examples I created were using this (baked-in) xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> '

Hi James,

I tried to create a xml file based on the templates you had provided above, however I am having issues reading it in ross. In this instance I have the name and number associated with each person, however I will also need a third variable to hold a location associated with each person. When trying to read the file into ross it appears that the Key value pairs do not appear. I am not sure if there is an issue with reading the file, however when I change the constrainttype from “INT_CHOICE” to “STRING_CHOICE” it appears that the names of are detectable in the edit component screen.

I have attached a copy of my file below, however I have removed several of the people in order to simplify the file.

Thank you

<?xml version="1.0" encoding="UTF-8"?> Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs ' var newConstraint = params.createIntChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) {

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“item”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var takeID = parseInt(node.getAttribute(“takeid”));
var name = node.getAttribute(“name”);
constraintData.push({“key”: takeID, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createIntChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

ogscript.rename('selected-take', this.getValue()); loadData('name-rep-number-xml.xml');

Hi Tejus

The constraints themselves are limited to key/value pairs. In the table examples I provided, you would be able to add additional fields by creating additional array parameters and adding them to the table.

If you want to include additional data in the dropdown list itself, you will need to concatenate the string yourself if you want to display it.

If you’re trying to include it in the value, you can change your parameter type from INT32 to STRING and change from createIntChoiceConstraint to createStringStringChoiceConstraint (and the constraint attribute in the parameter definition to STRING_STRING_CHOICE). You could then add additional data (again, via concatenation) to the value component.

Hi James,

Thank you for the information, I have tried to modify the parameters based on your suggestions however I am still having the issue where the key value pairs are not appearing in the parameter attributes section.

I have attached a copy of the new code as well as a picture of what I am describing. I am unsure whether its an issue with reading in the file or if there is something else I am missing. I know that you had mentioned that you created some sudo data for testing the functions, however after removing that it seems like the files are not being detected.

<?xml version="1.0" encoding="UTF-8"?> Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs
     </param>
  </params>
  <ogscript handles="onload">var newConstraint = params.createStringStringChoiceConstraint(["Nothing"]);

params.replaceConstraint(‘Constraint_From_XML’, newConstraint);
function getXML(file)
{

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“item”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var takeID = parseInt(node.getAttribute(“takeid”));
var name = node.getAttribute(“name”);
constraintData.push({“key”: takeID, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createIntChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

ogscript.rename('selected-take', this.getValue()); loadData('constraint-xml-tester.xml');

Below is the xml file that contains the initial data:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs
	</param>
</constraints>
Lastly I have attached a screenshot of the missing Name value pairs section:

Thank you once again for your help

Hi Tejus

I’m a little confused by your source XML file. The ogScript in the Custom Panel is looking for tags with attributes called “takeid” and “name” inside of the root document (see picture) but you appear to be embedding an , , and tag. The XML file is whatever you want it to be but this appears to be an odd collection of tags to use for your data.

The changes I had suggested for your file would look like this:

Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs var newConstraint = params.createStringStringChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) {

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“person”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var location = node.getAttribute(“location”);
var name = node.getTextContent();
constraintData.push({“key”: location, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createStringStringChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

ogscript.rename('selected-take', this.getValue()); loadData('constraint-xml-tester.xml');

And a companion data file would look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs

These are the changed areas to match the new file with the Custom Panel:

Hi James,

Thank you so much for your help!

I appreciate it!

Tejus

Hi James,

I hope you are doing well.

I had a couple questions regarding connecting datalinq to DashBoard. Based on the code you had provided last week I was able to get the xml working. However when I try to load the information from DashBoard to Datalinq I am having 2 issues.

Sometimes when I type a person’s name in and press load it appears that the name resets to something else than what I typed.

After loading a name and value from dashboard when I check the datalinq side, it appears that only the name is loaded and not the appropriate Precinct accompanied. I have attached a screenshot describing the second issue I am facing below.

Thank you for your help!

Tejus

Hi Tejus

You can expose as many parameters to DataLinq as you like. If you want to write additional details to DataLinq, you would create additional parameters and set their values whenever the selection in the dropdown list is changed.

You might want to look the example where I change the selection in the table based on whatever was searched for in the text field.

Hi James,

Thank you for your response.

I have tried to modify my xml file based on your xml version 2 you had posted above from a while ago. However I am still having issues separating the name and precinct into 2 separate columns in datalinq. Specifically when I add a new parameter to my existing file.

I have placed a version of my currently working xml file below, please let me know if you have any recommendations on how to split the precinct and names into 2 columns.

Thank you

Tejus

Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs var newConstraint = params.createStringStringChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) {

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“person”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var location = node.getAttribute(“location”);
var name = node.getTextContent();
constraintData.push({“key”: location, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createStringStringChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

ogscript.rename('selected-take', this.getValue()); loadData('constraint-xml-tester.xml');

Hi James, I just wanted to follow up on my previous question from a few days ago to see if there was a way to add a second parameter that would appear in datalinq, based on the code snippets from above.

I was also reading the openGear Development Guide and I noticed that there was a STRUCT that might be able to hold multiple sub parameters under it. Would that be a better alternative?

Thank you

Tejus

Hi Tejus
While you could use a struct to add additional parameter information, I don’t know if your use case is complex enough to warrant it. You can just create 2 new parameters to hold the 2 parts of the parameter (the selected value and the selected display name). You can then simply write to these parameters whenever they change and use THOSE for DataLinq.

Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs var newConstraint = params.createStringStringChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) {

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“person”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var location = node.getAttribute(“location”);
var name = node.getTextContent();
constraintData.push({“key”: location, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createStringStringChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

params.setValue('selected_precinct', 0, this.getValue()); params.setValue('selected_person', 0, this.getValueAsString()); ogscript.rename('selected-take', this.getValue()); loadData('constraint-xml-tester.xml');

Hi James,

Thank you for your help!

I think I now understand your idea, and I think that it should work.

I tried implementing it on a bigger dataset and its acting a bit strange as when I type a person’s name into the bar it prints a different person’s name below. Along with that sometimes when I press the load button, the name in the bar also changes. I have attached a screenshot describing the problem below.

Thank you once again for helping me through this process as I navigate Dashboard. I very much appreciate it!

Tejus

Hi James,

I just wanted to reach out as it had been a few days since I last posted regarding how the UI was sometime loading the wrong person (picture above).

I was thinking about it some more and I was wondering if the issue had to do with the fact that the key in this key/value pair was actually the person’s location instead of their name. Therefore when we search by the key which is the location, since there may be multiple people from the same location it prints out someone else’s details. Please let me know if I have this backwards and the name of the person is in fact the key. I am not really sure how to fix the problem as I tried to flip the name and location based on some of your earlier templates and it seems to have broken the UI.

Thank you once again for your help!

Tejus

Hi Tejus
I’m noticing your sample data reuses the same key for multiple display values (for example, I see Precinct 2 listed twice). Are these the ones behaving this way? If so, the problem is that the keys need to be unique. The workaround is to just use integer values for the keys (similar to the earlier examples) and write the precinct information to an array parameter (that you don’t show on the screen). You would then use the value of the name search field as the index of the string array to copy into the data linq value.

Hi James,

Thank you for your help!

Yes, I think the duplicate Precincts are causing the issue.
I think the idea you are describing could work as I do believe my dataset provides a unique number for each person. However would you be able to provide an example of how to incorporate the parameter array into my existing code, as I am not sure how to modify it for the .GRID file as well as the schema.

Thank you

Aaron Cunningham Adam Brandow Adam McCusker Albert Glenn Diggs var newConstraint = params.createStringStringChoiceConstraint(["Nothing"]); params.replaceConstraint('Constraint_From_XML', newConstraint); function getXML(file) {

return ogscript.parseXML(file); //Parse the XML
}

function loadData(dataFile)
{
var xmlDocument = getXML(dataFile); //Parse the XML
var nodeList = xmlDocument.getElementsByTagName(“person”); //Get the tags we want to include in the constraint
var constraintData = ; //Placeholder for the new constraint data

for (var i = 0; i < nodeList.getLength(); i++) //Loop through each tag we found
{
var node = nodeList.item(i); //Get the node
var location = node.getAttribute(“location”);
var name = node.getTextContent();
constraintData.push({“key”: location, “value”: name}); //Push the key/value pair
}

if (constraintData.length == 0) //Placeholder if we don’t have anything (OPTIONAL)
{
constraintData.push({“key”: 0, “value”: “Nothing”});
}

var constraint = params.createStringStringChoiceConstraint(constraintData); //Create the constraint
params.replaceConstraint(‘Constraint_From_XML’, constraint); //Replace the constraint
}

params.setValue('selected_precinct', 0, this.getValue()); params.setValue('selected_person', 0, this.getValueAsString()); ogscript.rename('selected-take', this.getValue()); loadData('constraint-xml-tester.xml');