Indirect Binding, Dynamic Views, Custom Prop Locations- Beginner Questions

Hi! I think I am making progress but wanted to still check somethings to make sure this is the best option.

Setup:

I have a root container tab, each tab correlates with a folder in my tag browser.

This UDT is just an interval tracker I made quickly, could be for when your furnace filter needs to be changed next ect

I am making a dashboard- on it I want to monitor all these dates, get notified when something is due soon, and be able to update Last Done.

Question 1 - Where should custom props live?

I am pretty green to Perspective and was originally making them on a textarea not realizing all the spots they can be added. For housekeep is it best in which- root, Coordinate Container, Text Area? The highest level they might be used? If only that Text Area will ever need it put it on that component but if two components on one container might ref it put it on the container etc?

Question 2 - Can my tab expression be done with a lookup instead?

I made this custom prop at Root to look for what Tab I am selected on.

If({this.props.currentTabIndex}=0,'Lexi',If({this.props.currentTabIndex}=1,'Nala','Lola'))

I have my tabs as ["Lexi","Nala","Lola"]- can this be done automatically with some kind of lookup and return instead of nested ifs?

Question 3 - Was breaking into custom props the right call or could it all be one expression or else where?

Goal was to get a TextArea showing Last Done dynamically based on tab and dropdown selection. Which has been completed in the process of making this post but still have questions.

Originally I was trying to reference the Last Done datetime memory tags in the expression and do all the handling in the expression but that didn't work for me and I remembered custom props, but I made them a direct tag reference. My old expression:

'Last '+ {this.custom.dropdownSeletion} + ' Shot: '+ if({../Dropdown.props.value}='DA2PP',{this.custom.da2ppDate},{this.custom.rabiesDate})

I found indirect tag bindings on the forum to automate custom props. Since the container and props were copied from Lexi's tab they were all hard coded to her tags and dates.

Now I was able to make a custom prop to output the date of the selected vaccine for whichever pet is being viewed so I can copy and paste this container and have it automatically work.

Now in my TextArea text I can use a simple expression and skip the if statement completely.

'Last '+ {this.custom.dropdownSeletion} + ' Shot: '+ {this.custom.returnDate}

Best to break items out for reuse and troubleshooting like this? Could it have all been done in one Expression binding?

Question 4 - Name reference breaks on inactive tabs, should I be worried?

The name ref in the indirect binding breaks when that tab is not being viewed.

Since its dependent on the active tab, when I am on Lexi, any other tab's TextArea will be in error. Any unintended consequences to worry about? It would be fine if the text area is view-only as it will update once visible again? Could skip the name ref entirely here for an alternative. Still want to keep each tab simple to duplicate.

Question 5 - Best way to write back to Last Done?

Where in the guide or what is the best way to write a new date to Last Done - button, DateTime Selector?


Looking forward to any thoughts, Thanks!

Question 1 - I always put custom props at either View or Root, as those are directly callable from anywhere in the structure. (view.custom.prop1 or root.custom.prop1) vs parent.parent.getSibling('FlexContainer1').custom.prop which breaks as soon as you need to add another container wrapper.

Question 2:

  • Copy your tabs property values to a custom prop at the view level.
  • Create a custom prop selectedTabIndex then bi-directionally bind the currentTabIndex of the tab component to it.
  • Create another custom prop selectedTabValue and use the following expression
{view.custom.tabs}[{view.custom.selectedTabIndex}]

Question 3: I generally break them down unless they're really simple. As you note, troubleshooting is easier. And also if you end up using that same chunk in multiple places, it's there and available.

Question 4: If all the different tabs show the same information, just for a different pet, why are you using tabs vs just a dropdown that changes the pet? It would make changes simpler since you'd only have to do it once.

Question 5: Depends. Do you just want the current date? Then a button is quick and easy. If you want to be able to backdate, or also set a time - datepicker.

Ahh I see, I got it to work. Thanks!

4- Initially it was just to see how the tab container works. I am assuming down the line they will have different items on each tab as they are dog, cat and fish. Dog has been fed check with a view at the week is what I really want. Fish tank sensors would be interesting to set up.

5- thanks

1- I also still need to look into the container wrapper mentioned earlier. Good to know that exist/ what to be on the look out for, thanks!

Unrelated, but i'm not sure how you're embedding your screenshots into the forum, but for some reason their quality is being severely reduced to the point of being illegible. They don't look compressed, they look like the resolution is reduced. If you're not aware, you can just snip the screen with whichever screen capture tool you use (snipping tool, greenshot, etc.) and just paste it into your post from the clipboard in full resolution and quality.