If the column width is set to 0 it does not hide the data in column.
I think it was reported before but can’t find the Feedback case.
Is there any update on this? In 2020r2.1 weblistbox does not hid columns even if columnwidth is set to 0 or 1 (tried 1 because 0 didn’t work). Tried shown event, opening event, setting in inspector, no avail. How can I hide a column i don’t want shown?
Don’t put the data in the listbox if you don’t want it shown. On web, making it zero width would still mean the data was sent to the browser and that someone could “see” it by looking at the page source.
it’s not confidential,but I just dont want that column to be displayed. It works in previous versions, so why not in 2020? thanks
Can you put the data into the RowTag instead?
I have some columns with data that must be included in the weblistbox and must be hide (not visible).
In previous xojo versions, solution is to set the columnwidth to 0.
Which is the way in the latest xojo version to hide a column of the weblistbox ?
No can do. Arbitrary column widths are not working in WebListBox 2.0, unless there is a JavaScript workaround.
Could probably come up with something but, with the way that the WebListBox re-renders, any action taken on it could overwrite the change. I’ll take a look.
Yeah, there’s just too much to workaround here, including explicit column widths. There is, however, an option for hidden columns in the underlying library to support this.
Decided to dig into the API. Place this method in a module:
Public Sub ColumnVisible(Extends lb as WebListBox, index as Integer, Assigns value as Boolean)
Session.ExecuteJavaScript( "$('#" + lb.ControlID + "_table').DataTable().column(" + index.ToString( "#" ) + ").visible(" + value.ToString.Lowercase + ");" )
End Sub
Call as:
Listbox1.ColumnVisible(1) = False
in the desktop listbox, I usually store hidden datas in columns after the columncount of the listbox.
they are still available, and they are not displayed
don’t know if this works in weblistbox.
edit: it does not work in 2021r11: xojo tests the columncount and throw an outofbound !
edit2: yes seems best way is to store what you need in the rowtag
Anthony - You are my hero! Works perfectly! Thank you!
@Anthony_G_Cyphers your solution is not working for me using Xojo 2022 r1.1
Anyone had tested this extended method in this Xojo version ?
Sorry… in the shown event handler works fine… not in the opening event handler
Just wanted to say “Anthony you are my hero!” as well
Anthony, I need to hide ID column (and other foreign key columns in the WebListBox), it looks like your solution work but only when I explicitly call the method while the WebListBox is populated. When the data comes back from the server the hidden column will show again. Also when I try to examine the element table in the browser the ID column becomes visible again.
I use Xojo2024R2.1 and the WebListBox with DataSource.
The code will not hide the ID column if I call it from the method rebuilding the list.
This is a common issue when trying to customize Xojo’s built-in Web components, and why I normally advise against it unless there’s no other recourse. The framework can, and will, re-render components in the browser and that negates any such modifications you’ve made using this method.
Now, as to why it’s not working after sending the same bit of JavaScript after the ListBox is re-rendered, it’s important to remember that not only is Web asynchronous, but the framework or library that the framework uses is likely using asynchronous methods to perform its own functions. This can result in the ListBox’s data being re-rendered after the extra JavaScript has run, negating its effect.
One potential solution is to call the function to hide the column by using Timer.CallLater, but even that carries risk of operating incorrectly or creating hard to find bugs. The correct solution, however, would be to never include data that you don’t want shown in the browser.
In short, either this needs to be added to the framework ListBox to be 100% reliable, or you should seek out a third-party component that offers this functionality.
You are correct, I can’t use the timer. I can hide any column that exposes the foreign key but I can’t hide the primary key cause I need it to fetch the data.
Hmm, I guess I am back to square one then.
You can store the key in the row tag, but not include a key column. That’s how it should be done.