I have some time today to look again. I think that I did something similar with filtering by league for my Sports statistics. Sports Standings and Scores
It could be buried in that code. Not sure but possibly you can sort and filter.
UPDATE: Yes it can be done and fairly easily, just need to figure out how to wrap things into a loop to make it all generic. But the key is like things for a decluttering template:
decluttering_templates:
cellartracker_settings:
card:
type: custom:flex-table-card
css:
table+: 'padding: 0px; width: 1600px;'
tbody tr td:nth-child(1): 'width: 6%;'
tbody tr td:nth-child(2): 'width: 40%;'
tbody tr td:nth-child(n+3): 'width: 6%;'
thead tr th: >-
background-color: green!important; color:white!important;
text-align:center; padding-top: 10px; padding-bottom: 10px; font-size:
18px;
tbody tr:hover: 'background-color: green!important; color:white!important;'
card_mod:
style:
.: |
ha-card {
overflow: auto;
max-height: 99vh;
}
$: |
.card-header {
padding-top: 6px!important;
padding-bottom: 4px!important;
font-size: 14px!important;
line-height: 14px!important;
font-weight: bold!important;
}
sort_by: row+
strict: true
entities:
include: sensor.test_cellartracker
columns:
- hidden: true
data: row
modify: if (x.Bin == 'B02') {x.Bin} else {null}
- name: Bin
data: row
modify: if (x.Bin == 'B02') {x.Bin} else {null}
- name: Wine
data: row
modify: x.Wine
align: left
- name: Vintage
data: row
modify: x.Vintage
- name: CT
data: row
modify: if(x.CT) {x.CT} else {'(empty)'}
- name: Quantity
data: row
modify: x.Quantity
This line enforces that the data must exist for all columns.
strict: true
Then changing the modify for each bin (above I used ‘B02’) … you get only the wines in that bin.
Now, if you only had a few bins you could just pass in the target bin as a variable. WOuld be much nicer to wrap the whole thing into something that automatically flexes to as many bins as we have.
But it is now mostly solved. I can move Bin to the title.
I will need to make some small modification to handle the no bin situation.
Update: I think you may need to enter something in Bin number in your collections. Trying to analyze what to do and sort it out based on unique bin numbers is not going to work.
I modified it to this but it does not support no Bin number
And now begining to love it …
I have implemented a way to sort on any column. In my opinion, that should remove the “Bin” separation and put Bin into a column that is sortable. Then you could sort by any column and maybe if we do it right, multiple columns (not sure). But bin could also be one of them. If you look at the picture above, it is sorted by Wine name within each bin.
I have 1000 bottle in house cellar and 10,000 bottle under house. I tend to say to myself …
Country → Varietal → maybe region … and then I want to know the bin to find it. Not a list isolated by bins for sure.
I am going to continue on building that, But next post I will give you handles the by bin tables. That will be removed in my final product.