I have a dynamic repeater which has checkboxes. I also have a nonrepeater "All" checkbox that I want to use to check or uncheck all items in the repeater. Clicking each repeater item turns on/off model parts.
Is there a way to get data from the repeater and do something like "for all items in repeater, check box". It looks like all the items are just called "checkbox-1". Is there a way to use the hashkey or something to programatically change the of one or all of the items?
I currently am using this code:
//==================================================================
twx.app.fn.clickItemInRepeater = function(item,list,isMultiSelect)
{
console.warn("called clickItemInRepeater()");
$scope.changeValueInJson(list,item.id_num,'checked', item.checked?false:true)
console.log("clickItemInRepeater::ROW Selected:: "+JSON.stringify(item))
console.log('checked?'+ item.checked);
if(item.checked==false){
$scope.currentSelection = 'model-1-'+ item.SBOM;
console.log('showing '+$scope.currentSelection)
tml3dRenderer.setProperties($scope.currentSelection,{opacity : 1})
$scope.mysubsystemlist[item.number].checked=true;
}
else if(item.checked==true){
$scope.currentSelection = 'model-1-'+ item.SBOM;
console.log('hiding '+$scope.currentSelection)
tml3dRenderer.setProperties($scope.currentSelection,{opacity : 0})
$scope.mysubsystemlist[item.number].checked=false;
}
console.log('sbom? '+item.SBOM)
$scope.$applyAsync();
};
Solved! Go to Solution.
- I think to have a code as you suggested in the pseudocode will be very convenient. But it seems not to work when I tested it. But still that should work when that internally is working with TWX.
IN studio with local data we need to change the data and set to the property. That is possibly the same internally when TWX is connected.
I tried in the past something similar - what was only attempt to have a workaround for such task but really not clean and supported way was there used. Here the project attached only if you want to see that as option.
I think I will address your question to R&D team (this week) so hopefully we will get a solution or hints from R&D -
Hi @JR_10569306 ,
dynamic repeater will means possibly that you want to change the data what is displayed by the repeater widget at runtime but I think the repeater is always dynamic depending on the data what are set to the repeater data property.
The question is what is required as action set all /unset / deselect all
is meant only all visible on the page datasets or there is meant all data - visible and not visible ?
so on the picture is there a list shown in the Text Area displayed in repeater with checkbox's.
So in case that I want to set/unset all then I could more easily change the property of all items in the list and then refresh .
But it will more more difficult if the data is coming form a Thingworx service which possibly does not display all elements. In that case you need a service which will change also in TWX. So therefore is important to know form where /TWX or local json list/ and how the data is set to the repeater widget -service TWX or local binding or JavaScript call
Thanks Roland.
Good point about all repeaters being dynamic.
The gist of it is a Thingworx loaded dynamic model is what populates the repeater. Technically the repeaterer is just being driven by a metadata json of the pvz. Every subassembly 1 level down will be listed in the repeater (e.g. /1,/2 , /3, ect). I have gotten the following working: Click a repeater-driven check box and that shows/hides the subassembly. I am also able to show/hide all subassemblies. The problem I am running into is showing/hiding all subassemblies AND updating the checkboxes to checked/notchecked at the same time.
The long and short of my question is, how would I do that in the code? I am looking for something like :
psuedocode: for(i=0, i< [repeater item length], i++){
$scope.view.wdg['repeater-1']['item-' + i].value=false
}
I am just not sure what the equivalent of: $scope.view.wdg['repeater-1']['item-' + i].value=false would be in this situation
- I think to have a code as you suggested in the pseudocode will be very convenient. But it seems not to work when I tested it. But still that should work when that internally is working with TWX.
IN studio with local data we need to change the data and set to the property. That is possibly the same internally when TWX is connected.
I tried in the past something similar - what was only attempt to have a workaround for such task but really not clean and supported way was there used. Here the project attached only if you want to see that as option.
I think I will address your question to R&D team (this week) so hopefully we will get a solution or hints from R&D -
Thanks,
I took what you said and I think I found a solution that works.
1. directly bind the "All" checkbox to the repeater checkbox. This accomplishes the "check all' functionality
2. Then update the array programmatically and set the "checked" value as true/false for all items in the array.
Right now that seems to be the best solution. Thank you for the help!
thanks for the feedback. make sense. BR