Page 1 of 1

Polygrid questions...

Posted: Wed Aug 23, 2023 12:44 pm
by paul@researchware.com
I see I have the properties of a polygrid for:

pgColumns -- an array of all column properties

and

pgColumnWidths -- a comma delimited list of widths

There does not seem to be a distinct property just for alignments, such as pgColumnAlignments

What I need to do is change the width and/or alignment of a specific column (that can change which column based on data). I can se no way of doing this other than repopulating the pgColumns array

If I try

set the pgColumnWidths of widget "rwTableview" to "300,75,75,75,75,75,75,75,75"

for example, that seems to have no effect.

If I try to just change one element of the column array, such as

put "300" into tArray[1]["width"]; set the pgColumns of widget "rwTableview" to tArray, it replaces all the other column information (names, etc.) with defaults (as I would expect)

Am I missing some syntax that will allow changing the name, label, width, alignment, or whatever property desired of a single column without touching any of the other column data already set?

Also, polygrid supports the "fixedFirstCol" (true|false) property for a while now. With this set to true, the first column can contain row labels that your want always visible while the grid is scrolled horizontally. Has anyone layered a control on top of the polygrid to act as a resizer for this fixed column? Somehting to (I imagine) change the column width of the first column as the control is move left or right. Does anyone know if your need to turn fixedFirstCol off (false) first and then back on after changing the column width? If someone has build a first column resizer, would you be willing to share it?

Re: Polygrid questions...

Posted: Wed Aug 23, 2023 1:51 pm
by dunbarx
Hi.

I have never used a polyGrid, but your comment:
set the pgColumnWidths of widget "rwTableview" to "300,75,75,75,75,75,75,75,75"
looks a lot like what one might do with a table field. My point is this: is it possible that your string of widths needs to be in array form, as opposed to a simple string of items?

Craig

Re: Polygrid questions...

Posted: Wed Aug 23, 2023 2:04 pm
by prometheus
The syntax
set the pgColumnWidths of widget "rwTableview" to "300,75,75,75,75,75,75,75,75"

is the right one, it works for me
Also you can use property 'tabStops', is a synonym for 'pgColumnWidths '

Re: Polygrid questions...

Posted: Wed Aug 23, 2023 2:18 pm
by prometheus
Regarding the alignment you could get the pgColumns, iterate over each key modifying the contentAlignment, something like this:

Code: Select all

on mouseup
   setColumnAlignment "right,left,right,right"
end mouseup

command setColumnAlignment pAlignments
   local tColumns
   local tColCount
   put the pgColumns of widget "PolyGrid" into tColumns
   put the numberOfColumns of widget "PolyGrid" into tColCount
   
   local tItemCounter
   repeat for each item tItem in pAlignments
      add 1 to tItemCounter
      if tItemCounter > tColCount then
         exit repeat
      end if
      
      put item tItemCounter of pAlignments into tColumns[tItemCounter]["contentAlignment"]
   end repeat
   
   set the pgColumns of widget "PolyGrid" to tColumns
end setColumnAlignment

Re: Polygrid questions...

Posted: Wed Aug 23, 2023 6:45 pm
by paul@researchware.com
That is what I was essentially asking. The only way to set column alignments (for example) is to get the entire pgColumns array from the widget, modify the alignment you want and then set the pgColumns of the widget to the modified array, which is what your setColumnAlignment handler does.

That's fine by me if that is the way to do it. I am a little concerned about performance, but before I write a bunch of code around a Polygrid, I just wanted to check if I was missing some hidden (to me at least) syntax that allowed setting of specific properties for specific columns.

I was imagining a syntax like:

set the pgAlignment of column "Delta" of widget "X" to "left"
OR
set the pgAlignment["Delta"] of widget "X" to "left"

Regardless of the syntax, it would be "nice" to be able to set labels, widths, alignments, etc. for a specific column without gaving to get the whole pgColumns array and then just modify the element desired and then set the whole array.

Re: Polygrid questions...

Posted: Wed Aug 23, 2023 8:04 pm
by prometheus
Totally agree, that would be very useful to have