Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
hello ptc community,
Is it possible that i can have filter in dropdown widget which can give me values which i can write in the field like for eg testing_value1, value2 are in the drop down and if i write val then suddenly these match value appears in the dropdown. Please let me know if its possible.
Thank you so much
@RolandRaytchev would you please share your opinion in this regard. thank you
Hi @MA8731174 ,
the dropdown widget - is here the 2D select widget meant?
Let's suppose that the select widget is meant. Depending on that for where we will get the data we can use different approaches .
Here for example we use a value of one list and change the value of the second list. - so means we can generate a list dynamically and set it to the list property of the select widget so that a new list is displayed.
Here in the example the value of one list is a filter for the second list. But you can use e.g. also a value of input widget that will also work
You can also add a new element to a list etc.
So possibly when you input a value /in input widget /then in the change event you will check the list and filter it or find specific value and then set the the List and value property of the select widget issue- possibly there is difference between the displayed name and the value .
Thank you so much for this clarification. I have only one list and want to write something first and filter and as you have mentioned that i can used input field to write something first and then with onchange function of it i can prepare my list and assign it to my select widget but question is how can i open the list without clicking on the select widget? is it possible because i cannot see the binding option to open the select widget on any kind of event. Please guide me further in this regard. Secondly about your approach with two select widgets when u select from first dropdown how you are opening the second list with clicking on the value in the first checklist. I am looking forward to hearing from you soon.
then filter that in the input
$scope.app.testListFilter=(theArray,filterKey)=>{
let retArr=[]
theArray.forEach(element => {
if(~element.display.toLowerCase().indexOf(filterKey.toLowerCase())) retArr.push(element)
});
return retArr;
}
the first argument is the list and the second is the filter string locking into to mach display fields and it return the filtered list
You can use also a filter to filter the data in the list from the binding , but there is difficult to use a $scope variable. Possibly somebody could help - how to use a $scope variable into the filter function. What will work is to use the window object e.g. window.myVar
where I used some code for the binding filter :
retArr=[]
let filterKey=window.my_filter
value.forEach(element => {
if(~element.display.toLowerCase().indexOf(filterKey.toLowerCase())) retArr.push(element)
});
return retArr;
But here we need to do some action so that the list should "know" that filter changed and to update. When data changes that will update using the current setting of the variable my_filter ... but changing the my_filter windows variable itself will not update the list automatically-because the binding filter will not fire at this point.