Android Question Query: Searching Multiple Columns

epiCode

Active Member
Licensed User
Is there a search example using customlistview / xCLV where

1. result is all rows from a single column matching the search string in multiple columns

B4X:
Col1    Col2    Col3    Col4
Alpha    21        25        35
Beta     15        25        0   
Gamma    32        26        67   
Delta    18        0        36

so for search string "0" it should return
Col1
Beta
Delta

PS: There is not much data to search from so Trie / Index methods might be an overkill and also they might not work with multiple columns unless tweaked.
 

epiCode

Active Member
Licensed User
Check B4XTable. It has such feature built-in.
I checked b4xtable and it was really helpful in understanding how search is implemented however there are a few constraints where your inputs will be of help

1. Scrolling is unavailable in CLVData, if multiple columns are visible (there is not much data in my search and "page view" feature does not appear appropriate for a search result which is supposed to be quick.

2. changing to vertical orientation also will not help because of how data is structured and added to CLV (horizontally)

But I've seen one example of both horizontal and vertical items in xclv (xclv VandH) and wondering if that can be done here.

I also checked flexible table class by klaus and that seems like a wonderful candidate but again it does not have search like b4xtable.

What I am looking for is pretty much the search that comes up with Ctrl + E in B4X IDE ( it is instant, Multi column, scrollable, highlighted results, +freeze column bonus)

How I wish Flexible Table to marry B4XTable soon and have B4XSearchlets ! :)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
How I wish Flexible Table to marry B4XTable soon and have B4XSearchlets
xCLV with an edittext or preferably a B4XFloatTextField as a search box is doable. If you want to attach your project with its SQLite database, or if you do not have a project, perhaps you can attach the database and explain what you exactly want, many members are very qualified to look at it, and who knows, you may get near what you wanted without having to consummate a marriage between B4Xtable and Flexible table
 
Upvote 0

epiCode

Active Member
Licensed User
xCLV with an edittext or preferably a B4XFloatTextField as a search box is doable. If you want to attach your project with its SQLite database, or if you do not have a project, perhaps you can attach the database, many members are very qualified to look at it, and who knows, you may get near what you wanted without having to consummate a marriage between B4Xtable and Flexible table
What I am looking for is pretty much the search that comes up with Ctrl + E in B4X IDE ( it is instant, Multi column, scrollable, highlighted results, + freeze column bonus)

What you are suggesting is what I tried first but - its like reinventing the wheel - and it does not support multiple columns ( I mean I could not get multiple columns to work correctly along with search)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
What I am looking for is pretty much the search that comes up with Ctrl + E in B4X IDE
It is similar to the algorithm implemented in B4XSearchView. Go over the code and understand how it builds the index. You can extend it in many ways, including to support multiple columns.

Though it will probably be easier to use B4XTable features.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
What you are suggesting is what I tried first but - its like reinventing the wheel - and it does not support multiple columns
You are so wrong in your statement. Here is an example that searches for a string in any of 3 columns, based on the search input in a B4XFloatTextField.. Before you draw quick conclusions, ask first. The answer may only be a post away:
B4X:
$"SELECT * FROM Jobs WHERE Name Like ?
    Or Job LIKE ? Or Salary LIKE ? ORDER BY Name"$, _
    Array As String ($"%${New}%"$, $"%${New}%"$, $"%${New}%"$))
 
Upvote 1

epiCode

Active Member
Licensed User
You are so wrong in your statement. Here is an example that searches for a string in any of 3 columns, based on the search input in a B4XFloatTextField.. Before you draw quick conclusions, ask first. The answer may only be a post away:
B4X:
$"SELECT * FROM Jobs WHERE Name Like ?
    Or Job LIKE ? Or Salary LIKE ? ORDER BY Name"$, _
    Array As String ($"%${New}%"$, $"%${New}%"$, $"%${New}%"$))
Thanks Mahares for the query!

Full Context Function:
dim fullContext as String= Select Quote from mohsyn
    Where fullquote = quote.quoted + partinBrackets
    Join in sequence
If fullContext = stillNoSense then callsub(youareSoWrong, (True))
 
Upvote 0
Top