Grid widgets and defaulting columns to HID

Author: i.sharp@pcisystems.co.uk (Iain Sharp)

We can now use the $columnsyntax proc to hide a column at runtime (Yay! Laugh). But if we want to define a column to either start hidden, or be hidden at all time (state etc fields) I think we still have to use the VISIBLE property of the grid widget.  If we do this, the column layout state is not stored for that grid widget.  Is there any easy way of defining a column at compilation time to be hidden which is not setting the VISIBLE parameter of the grid widget? Do I have to go through every program which uses grid widgets and alter the initialisation program to set $columnsyntax() for each of these fields to "HID" and then remove the VISIBLE parameter from the grid widget?  If $columnsyntax(XXX)="HID" does uniface store the layout state on exit?  Regards Iain

7 Comments

  1. Answering my own question. Using the $columnsyntax() to set the column to hidden causes it to stop storing the layout state on exit anyway.  So we are still in the situation where if fields are hidden from the user, then the layout of the fields they CAN see is not stored.  Oh dear.  Iain


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  2. More news, I have some additional code which when put in the viewport_resized and column resized extended triggers, appears to have the desired effect (storing the column sizes even with hidden fields.) I'm going to try and paste them below, but with this forum not having a <CODE> block, it's a chancy prospect. Viewport_resized trigger

    variables string v_stored_columns, v_column, v_entprop, v_newwidths numeric v_width endvariables v_stored_columns = $setting("","State\%%$applname%%%\forms\%%$componentname%%%\gridlayout_<$modelname>_<$entname>","REGDATA") if(v_stored_columns = "" | $item("VISIBLE", $entityproperties("<$entname>.<$modelname>")) != "") v_stored_columns = $encode("USTRING",$setting("","State\%%$applname%%%\forms\%%$componentname%%%\gridoverlayout_<$modelname>_<$entname>","REGDATA")) if(v_stored_columns != "") forlist v_column in columnWidthsPx v_width = $valuepart(v_column) v_column = $idpart(v_column) if(v_width > 0) if($item(v_column,v_stored_columns) != "") putitem/id v_newwidths,v_column,$concat($item(v_column, v_stored_columns),"px") else putitem/id v_newwidths,v_column,$concat($item(v_column, columnWidthsPx),"px") endif endif endfor ; set entity properties. putitem/id $entityproperties("<$entname>.<$modelname>"),"COLUMNWIDTH",v_newwidths endif endif

      Column_resized trigger

    variables string v_reg_set endvariables if($item("VISIBLE",$entityproperties("<$entname>")) != "")    v_reg_set = columnWidthsPx    $setting("","State\%%$applname%%%\forms\%%$componentname%%%\gridoverlayout_<$modelname>_<$entname>","REGDATA") = v_reg_set endif

    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  3. Seems there IS a code block, you just have to hack about until it magically appears and then edit the post.... 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  4. Iain Sharp said Seems there IS a code block, you just have to hack about until it magically appears and then edit the post.... 

    Thanks for sharing this. This is really a very useful tip! Cool Daniel


    Author: diseli (daniel.iseli@uniface.com)
  5. Iain Sharp said Answering my own question. Using the $columnsyntax() to set the column to hidden causes it to stop storing the layout state on exit anyway.  So we are still in the situation where if fields are hidden from the user, then the layout of the fields they CAN see is not stored.  Oh dear.  Iain

    I guess you also found the "fine print" in the documentation:

    Uniface Library > Uniface Reference > Widgets: Forms and Reports > Widgets: Forms and Reports: Layout Management [...]  The column sizes are stored in the registry and are automatically restored the next time the form is started. However, the layout of the grid is only stored when all columns have a size. This ensures that columns that may have been hidden (by $columnsyntax) are visible when the form is restarted. Row heights are not restored.

    Sorry that I cannot provide any better news. Daniel


    Author: diseli (daniel.iseli@uniface.com)
  6. I also detected that misfeature. What I am doing is the following: Just before closing the component I reset $columnsyntax, followed by a show-statement. For me it works fine. The layout is stored. Can be done generic without thinking of which columns are hidden or not. v_fldlst =  $entinfo(v_entname, "PAINTEDFIELDS") forlist v_fld in v_fldlst     $columnsyntax("%%v_feld%%%.%%v_entname") = "" endfor show Wolfgang


    Author: gypsilon (wva@gypsilon.de)
  7. Does that work when you have defined the fields in the entity parameters of the IDF as entity parameter VISIBLE FIELD=F?


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)