Hide Grid Column


#1

What’s the best way of hiding an AppStudio Grid column?


#2

If you’re referring to the common Grid control, maybe take a look at a similar issue addressed in the old AppStudio forum at:

Grid Control Issue

Personally, I like to work with my data in code using arrays, etc. then re-purpose (redraw) my Grid control for the modified data having the updated number of rows/columns. Modifying an already populated Grid on the fly can be challenging depending on the CSS involved.

Kind regards,
Doug


#3

I found setting the column width to 0 works but in some circumstances I’ve had to set the font colour to transparent as some data would be visible. I never worked out if it was data or platform that determined that.


#4

Hi Doug,

I have an yahoo account but can’t seem to have access to the old forum. Do you think you can re-publish the discussion (or the solution) here?

Kind Regards,
Paulo


#5

Here’s what is at that link:

This may not specifically answer your question(s) but several have tried to hide Grid columns in the past. You can search for the results here in the forum. The general responses follow one of two paths:

First, storing your data in an array and then populating the grid with only those elements you wish to display may avoid having to hide columns or attempting to filter grid data within the control. Instead, if needed, you can add or delete columns but do math/filtering operations on the array data instead.

Second, George has mentioned before that to hide a Grid column, you can:

“Put this into the grid’s style property:
table-layout:fixed;
The intent is to force the width of the column, not have it dynamic based on its contents.”

Then set the column width to 0. I myself tend to use the first path mentioned above.

Not trying to steer you in a direction, but passing along what others are sometimes doing.


#6

Thanks for the re-publish.

If you want to use the common Grid as a way of presenting array data to the user and use an hidden column to keep “key” data, I found a way of doing it.

When you load the Grid from an array in your For…Loop simply use this:

Grid.cell(n,x).style.display=“none”

Being x the column you want to hide. You need to do this for all the rows or it doesn’t work.

Hope this helps someone else.

Best Regards,
Paulo


#7

You could also use the hidden property. To see it in action, replace the GridWithScrolling sample project onclick function code with this code, then click on the grid to toggle the effect:

Function Grid1_onclick(event) 'event
  Dim row, col, scrollerWidth
  For row = 0 To 9
    For col = 0 To 3
      If col = 1 Then
        If Grid1.cell(row, col).hidden Then
          'col 1 is hidden, so displays it
          Grid1.cell(row, col).hidden = False
          Grid1.setColumnWidth(1, "50px")
          scrollerWidth = "200px"
        Else
          'col 1 is visible, so hides it
          Grid1.cell(row, col).hidden = True
          Grid1.setColumnWidth(1, "0px")
          scrollerWidth = "150px"
        End If
      End If
    Next
  Next
  'resizes the grid scroll bar width to fit
  Grid1_scroller.style.width = scrollerWidth
End Function

Kind regards,
Doug


#8

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.