Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I have a drop down widget which is dependent on another drop down. So when I select the first drop down the second drop down get's populated respectively.My requirement is that when my second drop down is populated if the list has only one value(i.e 1 row) it needs to get auto selected, but if it has more than 1 value in the list I don't want the auto select option.So I cannot use the "Auto select first row" property as it will not satisfy in case I have a list with more than 1 value.Is there a way to configure my drop down such that it get's auto populated only if 1 value is present in the list.
Solved! Go to Solution.
For my test I used ThingWorx 8.5.2. With that version I was able to accomplish your goal.
I defined an info table which was part of a thing and a Service.
I used the Thing Service GetProperties to return the infotable which I linked to the dropdown widget data field.
The ServiceInvokeCompleted event on the GetProperties to run a service I created SetSelectedRow.
This service takes one input an infotable from GetProperties and has one output an InfoTable which is linked to the dropdown widget Selected Data.
The code in my service looked like:
var listCount = inDropDownTable.getRowCount();
var params = {
infoTableName : "InfoTable",
dataShapeName : "Community-Dropdown-V1-DataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(Community-Dropdown-V1-DataShape)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
if (listCount == 1) {
// Community-Dropdown-V1-DataShape entry object
var firstRow = inDropDownTable.getRow(0);
var newEntry = new Object();
newEntry.id = firstRow.id; // NUMBER [Primary Key]
newEntry.Value1 = firstRow.Value1; // STRING
result.AddRow(newEntry);
}
// Return value is empty table when more then 1 row
// Return value is info table with one row when input has one row.
Let me know if you have any questions.
Peter
Your service can evaluate how many records are being returned and provide a return of two infotables.
one infotable has the payload for the dropdown, the second payload has the information for Selected Row for the drop down.
I didn't quite get that.
What i have done now is I am getting the count of the rows displayed in my second dropdown.I have set up a validation to check if the row count is == 1, is there anyway for me to execute or bind the true property of the validator function to the the auto select first row property of the drop down and make it true only when row count ==1?
Or bind selected items to the dropdown when the validator is true?
I don't think auto select first row is bindable.
So my approach is using a service that determines both what is displayed in the second dropdown plus an additional infotable that has the selected row value.
you would not use auto select first row at all.
For my test I used ThingWorx 8.5.2. With that version I was able to accomplish your goal.
I defined an info table which was part of a thing and a Service.
I used the Thing Service GetProperties to return the infotable which I linked to the dropdown widget data field.
The ServiceInvokeCompleted event on the GetProperties to run a service I created SetSelectedRow.
This service takes one input an infotable from GetProperties and has one output an InfoTable which is linked to the dropdown widget Selected Data.
The code in my service looked like:
var listCount = inDropDownTable.getRowCount();
var params = {
infoTableName : "InfoTable",
dataShapeName : "Community-Dropdown-V1-DataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(Community-Dropdown-V1-DataShape)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
if (listCount == 1) {
// Community-Dropdown-V1-DataShape entry object
var firstRow = inDropDownTable.getRow(0);
var newEntry = new Object();
newEntry.id = firstRow.id; // NUMBER [Primary Key]
newEntry.Value1 = firstRow.Value1; // STRING
result.AddRow(newEntry);
}
// Return value is empty table when more then 1 row
// Return value is info table with one row when input has one row.
Let me know if you have any questions.
Peter
Thanks a lot.