184
Views
10
Comments
Solved
Dynamically hiding table columns - body col works but not header
Question
Application Type
Mobile
Service Studio Version
11.54.50 (Build 63188)

I have followed an excellent guide to making a table column visible/invisible by using a row cell attribute style = If(criteria,"Display:None","") and this works great, but on the header cell the same entry does not result in the heading column being hidden and you end up with body content (rows) being moved left and no longer matching the column headings. Any ideas please?  

UserImage.jpg
Martin Sutherland
Solution

I finally just created multiple containers each with a table (which could then have different columns) and then hid or made these visible based on another dropdown value. Thank you for your efforts to help me

2019-03-19 12-24-07
Mariano Picco
 
MVP

That's a solution, for sure, but I feel that's a bit "brute forcing" what you want to happen. The method I proposed allows you to hide any column you want, and any combination of columns. 

Does switching between these tables make the screen sort of blink and refresh? 

2019-03-19 12-24-07
Mariano Picco
 
MVP

Are you controlling your visibility with Booleans? If so, you can give the same boolean to hide the header and the row cell:

Both the Cell and the Header have the same style attribute.

This was a quick test, and it works, but I wouldn't do it this way, probably I would use CSS Classes instead of forcing an inline style. 

Also, the total table width doesn't change and so the remaining columns resize... which doesn't look great. You'll have to manually adjust for that. 

UserImage.jpg
Martin Sutherland

Thank you Mariano, I did indeed use the same boolean IF construct in both table header and cell and it works in cells but ignored in the header. Perhaps the inline style is getting overridden in the header due to other styles being used for a header? Are you trying in a PWA?

2019-03-19 12-24-07
Mariano Picco
 
MVP

Using reactive web. You can inspect the table in your browser and find out what styles are being applied

UserImage.jpg
Martin Sutherland

Thank you, I seem unable to use via a full web browser and get the message "Your app requires native access to a Local Storage database that is not available in your browser while using an iframe.

Please test your app in your mobile device or use Google Chrome"

So, I just test on my mobile and I don't think that provides inspection etc

If the in-line style is getting ignored for some reason, then I must come up with a new plan. Did you mention creating a CSS style in some way? 

2019-03-19 12-24-07
Mariano Picco
 
MVP

Well, have you tried debugging with Chrome? 

Yeah applying a Class instead of inline styling, but since inline styling takes precedent (overrides) to style sheet classes, that wouldn't really solve the problem. 

Give the inspect a try

UserImage.jpg
Martin Sutherland
Solution

I finally just created multiple containers each with a table (which could then have different columns) and then hid or made these visible based on another dropdown value. Thank you for your efforts to help me

2019-03-19 12-24-07
Mariano Picco
 
MVP

That's a solution, for sure, but I feel that's a bit "brute forcing" what you want to happen. The method I proposed allows you to hide any column you want, and any combination of columns. 

Does switching between these tables make the screen sort of blink and refresh? 

UserImage.jpg
Martin Sutherland

Hi Mariano, I did use the same boolean test in header cell and body cell and as mentioned, it just does not work for the header cells so you end up with the wrong header cells above body cells. Not sure how it works for you. Inspecting the CSS info probably isn't going to help, so I just had to go with another solution. It does seem to work OK though with no blinking/refresh issues. Thank you

2019-03-19 12-24-07
Mariano Picco
 
MVP

Hi Martin, 


That's a shame it's not working on yours. I made an example .oml to show you how I was proposing to implement it, let me know if it was the same way you were trying it and if it doesn't work.

HideColumns.oml
UserImage.jpg
Martin Sutherland

Sorry, I will try your oml file and see if it works for me. Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.