简体   繁体   中英

Aurelia Value Converters using array

I have a question with Value Converters, I have an array w/c filters inactive item, when I am editing an item and change the status property to 'INACTV', the table does not change. but when adding/removing items in the array, it refreshes, my workaround is creating a binded _signal property to force the filtering, is there a way not to do this?

< tr repeat.for="item of ARRAY | filtercustom:'STATUS_CD':'INACTV':_signal" >

I'm not sure I understood how the filter is supposed to work. But if it should hide inactive items, maybe you could do something like

<tr repeat.for="item of ARRAY" if.bind="!item.STATUS_CD='INACTV'">

I don't know if it is possible to put a value converter inside a "repeat.for". Looks weird.

I hope this helps to push you in the right direction.

No, there is no direct, clean way to do this at the moment. Repeat.for uses a CollectionObserver for array observation which only responds to pop/push/reverse/shift/sort/splice/unshift.

Only when one of these methods is called on the array, the observer fires and the array is fed to your ValueConverter again.

Your signal solution is about as clean as it gets. It's more efficient than the alternative of refreshing the whole array from manually instantiated property observers on your STATUS_CD property on every item in the array. Which is what I do in some similar situations, because I don't like using signals. But that's just a matter of preference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM