How to search empty entries in QfilteredDatagrid?

5 replies [Last post]
tronics's picture
Offline
Joined: 04/06/2008

Dear community,

I have a question on how to use QfilteredDatagrid.
We want to search for an empty field. However empty filter textboxes are treated as if this was not used in the filtering.

What is the best way to adapt the filtering to find empty values for example by entering "" into the corresponding filter textbox?

Interesting that this never came up before.

Thanks.

Best,
tronics

Offline
Joined: 10/11/2010

I think the code wherein you add the column can be customized?

Regards

tronics's picture
Offline
Joined: 04/06/2008

Thanks.
I have the MySQL ready to put into the filtering process for the corresponding fields to make these things happen.. but I do not know how to change that code.

Ideally it would be possible to do that when configuring the filters.
A link to a similar solution or a code sample would help a lot.

Another thing I do not get is how to change between similar datagrids and transferring the filter values via a simple link (no replacing of the datagrids via ajax).

Best,
tronics

Offline
Joined: 10/11/2010

As of now, I dont have much idea. But I will try to look into it within a week (busy these days and the only thing I am doing is Qcubed apart from checking email and writing code). Chances are that I might forget. Please remind me by just bumping this thread. I will get an email notification that way!

Interestingly enough, I myself have been in need to replacing the datagrid thing and I did write some code about how to switch. It was actually just a panel and I would make a datagrid visible and rest invisible. Turned out that when datagrids are 'similar', It is better (both ease of writing the code as well as the performance) to do Ajax and remove & add columns dyamically than replace datagrids as a whole.

Regards,
Vaibhav

vakopian's picture
Offline
Joined: 04/08/2008

tronics,
I don't think this is possible with the current QDataGrid filters. Mostly it's a UI limitation: when you have a simple textbox for a filter, how do you specify that you need to filter on the empty string vs. no filter at all. The same question is there if you want to search for NULLs. So to handle this you would need custom filter controls (e.g. a text box and dropdown with choices such as "search for empty only", "search for nulls only", "include nulls", etc).

There has been some work done for allowing custom controls for the QDataGrid, but it was not fully finished and tested, so it will not be in the upcoming release. However, it would be greate if you could test and/or enhence it. The main ticket with the patch is #714. There was some discussion about similar features on #568.

tronics's picture
Offline
Joined: 04/06/2008

Thank you for your feedback.

I understand what you are saying but I do not necessarily go as far as put another custom control element on that column.

Basically I could introduce some special search inputs like: <> and ''
Where one searches for not empty and the other one for empty intercepts the normal filter query.

But I wonder where to catch the value entered in the filter column by a custom function.

I will go and checkout those mentioned tickets as well. Thanks.

Best,
tronics