You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When users configure filters in Tab 2 and apply them, I need the table in Tab 1 to update and show only the filtered rows.
Current Setup
I have a table with a filter function that references external state:
typeModelstruct {
table table.ModelfilterCriteriaSomeFilterState// External state provided/updated by Tab 2
}
func (m*Model) createFilterFunc() table.FilterFunc {
returnfunc(input table.FilterFuncInput) bool {
// Filter logic that depends on m.filterCriteriareturnmeetsFilterCriteria(input.Row, m.filterCriteria)
}
}
// Initial table buildm.table=table.New(columns).
WithRows(rows).
WithFilterFunc(m.createFilterFunc())
The Problem
When m.filterCriteria changes (triggered by user actions in Tab 2), the table in Tab 1 needs to re-evaluate which rows should be visible.
Important: I've verified with logging that m.filterCriteria is correctly received with the updated data in Tab 1's Update method. The data flow is working correctly, but the table UI doesn't visually update to reflect the new filter criteria.
Calling following in the Update method:
case models.FilterStateMsg:
ifmsg.State!=nil {
m.filterState=*msg.State
}
m.table=m.table.WithFilterFunc(m.createFilterFunc())
returnm, nil
...doesn't seem to trigger the table to re-filter existing rows. The table displays the same rows as before, even though the filter criteria has changed.
I've also tried the following which doesn't work either:
case models.FilterStateMsg:
ifmsg.State!=nil {
m.filterState=*msg.State
}
m.table, cmd=m.table.Update(msg)
returnm, cmd
Question
Is there any way to trigger the table to re-evaluate its filter function on existing rows when the underlying filter criteria changes?
The filter criteria itself is updating correctly, but I can't figure out how to make the table's visual display update to reflect the new filters.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I have a tab-based UI where:
When users configure filters in Tab 2 and apply them, I need the table in Tab 1 to update and show only the filtered rows.
Current Setup
I have a table with a filter function that references external state:
The Problem
When
m.filterCriteriachanges (triggered by user actions in Tab 2), the table in Tab 1 needs to re-evaluate which rows should be visible.Important: I've verified with logging that
m.filterCriteriais correctly received with the updated data in Tab 1'sUpdatemethod. The data flow is working correctly, but the table UI doesn't visually update to reflect the new filter criteria.Calling following in the
Updatemethod:...doesn't seem to trigger the table to re-filter existing rows. The table displays the same rows as before, even though the filter criteria has changed.
I've also tried the following which doesn't work either:
Question
Is there any way to trigger the table to re-evaluate its filter function on existing rows when the underlying filter criteria changes?
The filter criteria itself is updating correctly, but I can't figure out how to make the table's visual display update to reflect the new filters.
Thanks for this excellent library!
Beta Was this translation helpful? Give feedback.
All reactions