[SOLVED] ColumnWidth in Grid Widget

Author: maciokr@natfuel.com (RobM)

Uniface help states that I can get the columnWidth of a Grid widget field but does not give an example: Use $entityproperties to set (or get) the value of the ColumnWidth property...   If I have a field named Adj_Volume in table Group_Adjustment how would I use $EntityProperties to get the width of Adj_Volume in a Grid I have painted on the form?   Ideally, I'd prefer the user not be allowed to adjust the column sizes for this particular form but find no property for that.  I want to set the columns back to the original widths using the Column_Resized extended trigger if the user resizes on their own so I have to capture the original widths.   I can set the width without issue. Thanx, ..Rob..

6 Comments

  1. Hi Rob, only columns that were already explicitely set width are returned into ColumnWidth from a $entityproperties(MYENTITY). Hope it helps. Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  2. Hello Rob For fixed layout the proc could like like this: trigger Viewport_Resized params numeric widthPx : in numeric heightPx : in string columnWidthsPx : in endparams ;only 1 time if ($columnwidths$ = "") ;catch the start sizes $columnwidths$=columnWidthsPx endif end ; trigger Viewport_Resized trigger Column_Resized params string columnName : in numeric viewportWidthPx : in string columnWidthsPx : in endparams variables string thename, colWid , entProp , valuepairs , valuepair numeric thewidth endvariables ; get current entity properties. entProp = $entityproperties(UGRID_PERSON.UGRID) ; delete the current columnwidth property. delitem/id entProp, "columnwidth" ;valuepairs = columnWidthsPx valuepairs=$columnwidths$ ;get the value for each field while (valuepairs != "") getitem valuepair , valuepairs , -1 ;get last item from list thename = $idpart(valuepair) thewidth = $valuepart(valuepair) putitem/id colWid, thename, "%%thewidth%%%px" delitem valuepairs , -1 ;remove this field from list endwhile ; add the new columnwidth property. putitem/id entProp, "columnwidth", colWid ; set entity properties. $entityproperties(UGRID_PERSON.UGRID) = "%%entProp" end ; trigger Column_Resized ; -- end triggers for grid widget Peter


    Author: PBeugel (peter.beugel@uniface.com)
  3. Peter,   This works perfectly.  Obtaining the starting values via Viewport_Resized (1st time only) allows me to put the columns back to their original widths. Thanx! ..Rob..


    Author: RobM (maciokr@natfuel.com)
  4. One remaining issue:  I attempted to apply this to a grid painted on an inner entity and the Viewport_Resized trigger does not fire until a column has been resized to change the viewport.  The column widths it saves are after the user has made the first adjustment.  If a column is resized smaller than original, it remains resized smaller.   Is there a way to cause the  Viewport_Resized trigger to fire via proc?


    Author: RobM (maciokr@natfuel.com)
  5. Hello Rob, What version and patch level are you using? There were some problems in the past with the Viewport_Resized trigger, but these should be fixed with the version 9.6.06 patch X603 (and higher) or version 9.7.01 (and higher). Hope this helps. Daniel


    Author: diseli (daniel.iseli@uniface.com)
  6. diseli said Hello Rob, What version and patch level are you using? There were some problems in the past with the Viewport_Resized trigger, but these should be fixed with the version 9.6.06 patch X603 (and higher) or version 9.7.01 (and higher). Hope this helps. Daniel  

    9.6.05 x502   Going to 9.7 soon. Thanx! ..Rob..


    Author: RobM (maciokr@natfuel.com)