I looked in the sample files but could not find any sample for using the WebListBox.SearchCriteria
I have tried it, and it does find the things it is looking for, the problem, in my case, appears to be that the Row Indexes or the weblistbox itself is not updated until after the function has completed.
/
//---- This part works ----//
grdAccounts.SearchCriteria = Me.Text
If grdAccounts.RowCount = 0 Then
MessageBox " Could not find " + Me.Text
Return
End If
//---- Found one record ----//
Dim RowCount As Integer = grdAccounts.RowCount <<==== This returns a 1
Dim Row As Integer = grdAccounts.LastRowIndex <<==== This returns a zero since it should be the first record.
//---- This does NOT work ----//
If grdAccounts.RowCount = 1 Then
grdAccounts.SelectedRowIndex = Row
grdAccounts.SelectedRowColor = Color.Blue
grdAccounts.ScrollTo(0)
End If
Further, it appears the weblistbox is not updated which is why the coloring of the row does not work. It also throws off other code that is after this and relies on getting the data in the first field of the LastRowIndex.
This is making me wonder if I am doing this correctly or if some more code needs to be added so the WebListBox is updated on the fly?
Color it - of course⦠but, the problem appears to have more to do with the fact that the WebListBox is not updated until after the method is completed.
Why you want to color the row?
The result can be 0, 1 or multiple rows depending on the search.
Usually the user on the webpage selects the row if/when needed.
Yes, I know that it. Did you see my code? It only wants to color it if there is only 1 row.
Again, I think it is a problem where the WebListBox itself is not update until after the search code is executed. It appears to be correct with the right row count (not just 1 row but multiple too) So eventhough the search says there are only 1, 4 or whatever number of rows, the reality is, when you try to do something with the row returned (in the case of 1 row) the actual data that is retrieved later references the original data that was in the first row.
Dim Row As Integer = grdAccounts.LastRowIndex <<==== This returns a zero since it should be the first record.
Iāll make a sample when I get some time.
Try it yourself tho. Populate like 10 different rows with different data - maybe the first column just a number. Search so the 7āth Item is selected during the search. Then try to anything with would now be row 0. Youāll get the original data from what was entered in the beginning as row 0.
No, that is not the problem. SearchCriteria searches for matches and whatever does not match is not showing but still on the Listbox.
You may see only 1 row, but that row, unless is the real first row, is not row 0. If your search finds only row 0, you can SelectRowIndex = 0 there.
The search items do not convert the resulting rows to a different row number.
Try it yourself, add Press method to listbox, search for something that is not row 0 and the listbox only shows 1 result, then on Pressed check for the Row that you pressed, it will not be row 0.
Note: Iām not saying that there are no bugs here, but what I was able to find by testing a little. Maybe a problem with original information and showing information. Depending on the example that you create, you can file a bug report.
Edit: maybe a bug or bugs with the relation of original listbox and searched listbox? For example what you say about LastRowIndex (new info) and other results are for the original listbox (content, actual row number, etc.)
When you do a WebListBox.SearchCriteria, the listbox only shows the results of the search.
After the search LastRowIndex, RowCount, and I guess others, are giving results of this new limited Listbox (maybe only 1 record).
The Listbox still contains all the original records.
If you add a Press event and you click on the found record, it will not say Row 0 but the original Row number (on my screenshot above Row 49).
And that is why you canāt color your row. Row 0 can only by selected/colored if the first result is Row 0.
BUT - I need to get the info from the ālimitedā Listbox. There is no way to know what the actual row is - correct? Soooo how to get the info, the limited listbox row numbers?
You guys do understand that the WebListBox always uses a DataSource, right? When you donāt define a DataSource, an in-memory SQLite database is created for each listbox and attached to it as if it were its DataSource. Because of that, it is asynchronous. So when you set the search criteria, the listbox is told to reload and the client side control requests its visible rows again.
Edit: Sample code that you can modify WeblistboxSearch.xojo_binary_project.zip (9.7 KB)
the goal is to have code to show 50 on the dialog after first search and 10 after the second search CellTextAt(0,0) button.
Assuming nothing has changed (and based on how complex the code is that makes weblistbox work, I donāt think you can expect CellTextAt to behave the way it does on the desktop. The trick is that itās the filtering and ordering of the DataSource that changes so that, if you were to scroll to another portion of a list that filtered is still hundreds of lines long, the correct portion of the list can still be retrieved. What this means is that CellTextAt would need to actually query the DataSource to get you that information which could be a single field out of thousands or even hundreds of thousands of rows.
Personally, I think it would be better for you to do your own DataSource in this case and apply any search criteria yourself. Then, if your very own row count method were to return 1, youād be able to know that something special needed to be done. Basically you add your own SearchCriteria property to the object that represents your DataSource and just apply that to the query you use in the RowCount method as well as in the RowData method.
What you suggest is exactly how I did it. I was looking at refactoring to take advantage of the
built-in search, which I thought would be faster and less processor intense.
Is there a way to know which end processing takes place for code I write? That was another consideration - thinking it would take place on the client side.
If youāre writing code in Xojo, it always runs in the server. Only controls written with the WebSDK in typescript /javascript run code on the browser itself.