1. John Vanleeuwe
  2. PowerBuilder
  3. Tuesday, 9 January 2018 05:44 AM UTC

HI all,

i have a grid datawindow with a few columns that our users can drag & drop left and right in the order they like.

is there any way how to get the name of the first column , second , ... from left to right please ?

 

tia

john

 

Accepted Answer
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 9 January 2018 10:05 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi John, here below the code (credits to René's idea).
In essence: 1) create a temporary datastore for storing columns' name and x, 2) fill the DS scanning the columns, 3) sort DS by x.
Cheers,
Marco

datastore lds_temp
String ls_err, ls_colname
Long i, ll_colx

// Build a temporary DataStore for column sorting
lds_temp = CREATE datastore
String ls_dsdef = 'release 12.6; datawindow() table(column=(type=char(30) name=colname dbname="colname") column=(type=number name=colx dbname="colx"))'
lds_temp.CREATE(ls_dsdef, ls_err)

// Insert Column name and x
For i = 1 To Integer(object.datawindow.column.count)
    ll_colx = Long(Describe('#' + String(i) + '.x'))
    ls_colname = String(Describe('#' + String(i) + '.Name'))
    lds_temp.InsertRow(0)
    lds_temp.SetItem(i, 'colname', ls_colname)
    lds_temp.SetItem(i, 'colx', ll_colx)
Next

// Sort by x
lds_temp.SetSort("colx ASC")
lds_temp.Sort()

// Display
For i = 1 To lds_temp.RowCount()
    MessageBox("Position: " + String(i), "Name: " + lds_temp.GetItemString(i, 'colname'))
Next

DESTROY lds_temp
Comment
  1. Matthew Balent
  2. Tuesday, 9 January 2018 12:49 PM UTC
One minor note, you might want to check the visible property of the column in case there are some 'non visible' columns within the dw.

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 9 January 2018 06:13 AM UTC
  2. PowerBuilder
  3. # 1

The only way I know is to get the x position of each column. The first column is the one with the smallest x position.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.