WSortFilterProxyModel does not filter
I have a WTableView object connected to a model object of type WSortFilterModel which in turn is connected to an object of type WStandardItemModel. The tableview initially renders the data just fine. But when I try to filter, however, the data disappears from the tableview. Relevant code is below (I use a WTextEdit to input filter data and a WPushButton to trigger the filter on column 5 of in my model):
construction and initialization of filter model:
m_filter_model = new Wt::WSortFilterProxyModel(root())
m_filter_model->setFilterRole(Wt::UserRole); /// btw, i also tried the DisplayRole. same behaviour.
Here I trigger the filter but the data in the view disappears:
m_filter_model~~setFilterRegExp(m_filterEdit~~>text()); // I checked to make sure there is indeed the correct filter text.
Help is appreciated,
Updated by Suresh Easwar almost 8 years ago
I've attached two images. I was attempting to retrieve a single row based on a specific value in column 5 (ORDER_ID) - see Before.PNG. The After.PNG file shows what I see after the filter has been applied. When I clear the filter editbox and press the OK button all the rows are restored. Also .* seems to work but regexps like KGAN.* does not.
Updated by Koen Deforche almost 8 years ago
- Assignee set to Koen Deforche
Wt::UserRole seems an odd choice, unless you actually specify proper UserRole data. If you do not have UserRole data then that would explain the behavior you see.
If you set Wt::DisplayRole then this should work, if not, can you isolate the code in a test case so that we can figure out what is the problem.