Complex Grid
Jean-Marc VOEGELI
jmvoegeli at bluewin.ch
Tue Nov 1 05:18:36 EDT 2016
Hello Wendy,
> I have a complex grid with 9 columns - is there a simple way to change the
> order in which the columns are displayed rather than manually moving the
> headings and data items?
Here is a method to invert two columns.
This complex grid has buttons in its title to sort the list by irs column data name.
There is also another method to insert a new column, but it is much more complex.
HTP
Best Regards
Jean-Marc VOEGELI
Tél. : 022 784 34 80
Fax : 022 784 23 40
Natel : 079 416 35 34
eMail : jmvoegeli at bluewin.ch
Text of method follow :
##### Method 'Intervertir_Deux_Colonnes' #####
No. Parameter Type Subtype Init.Val/Calc Description
1 pLib Character 255 "Paiements" Nom de la library
2 pFen Character 255 "w_Paiements_SubList_Essai" Nom de la fenêtre
3 pList Character 255 "Liste" Nom de l'objet "List" dans la fenêtre
4 pBut_1 Character 255 "Btn_ParIdentité" Le plus petit (le plus à gauche, le premier dans la fenêtre)
5 pField_1 Character 255 "lst_ParIdentité" Le premier champs
6 pBut_2 Character 255 "Btn_Comptabilité"
7 pField_2 Character 255 "lst_Comptabilité"
8 pNbDeCols Long integer 81 Nombre de colonnes
No. Local Variable Type Subtype Init.Val/Calc Description
1 vBut1Ref Item reference #NULL
2 vBut2Ref Item reference #NULL
3 vCol1 Long integer 0
4 vCol2 Long integer 0
5 vDiv1Ref Item reference #NULL
6 vDiv2Ref Item reference #NULL
7 vField1Ref Item reference #NULL
8 vField2Ref Item reference #NULL
9 vItem Item reference #NULL
10 vListRef Item reference #NULL
11 vNbDeCol Long integer 0
12 vPos1Div Long integer 0
13 vPos2Div Long integer 0
No. Method text
1 ; En tant qu'objet dans une fenêtre ::: Complexe Grid
2 ; Not This ::: You can move a column to a new position using the '$ident' :: 'Do List.$cols.1.$ident.$assign(3)'
3
4 ; INITIALISATIONS
5
6 Set reference vListRef to $root.$libs.[pLib].$windows.[pFen].$objs.[pList] ;; Liste dans la fenêtre
7
8 Set reference vBut1Ref to vListRef.$objs.[pBut_1]
9 Set reference vBut2Ref to vListRef.$objs.[pBut_2]
10
11 Set reference vField1Ref to vListRef.$objs.[pField_1]
12 Set reference vField2Ref to vListRef.$objs.[pField_2]
13
14 Calculate vCol1 as vBut1Ref.$gridcolumn
15 Calculate vCol2 as vBut2Ref.$gridcolumn
16
17 ; TEST DE FAISABILITE
18
19 If (vCol1>=vCol2)|(vCol1<=0)|(vCol2<=1)
20 Quit method kFalse
21 End If
22
23 ; ECHANGE
24
25 Set reference vDiv1Ref to vListRef.$dividers.[vCol1]
26 Set reference vDiv2Ref to vListRef.$dividers.[vCol2]
27
28 If (vCol1>1)
29 Set reference vItem to vListRef.$dividers.[vCol1-1]
30 Calculate vPos1Div as vDiv1Ref.$posn-vItem.$posn ;; Ce qu'on doit ajouter au divider précédent
31 Else
32 Calculate vPos1Div as vDiv1Ref.$posn
33 End If
34
35 Set reference vItem to vListRef.$dividers.[vCol2-1]
36 Calculate vPos2Div as vDiv2Ref.$posn-vItem.$posn
37
38 Calculate vNbDeCol as [vListRef.$dataname].$colcount
39 Calculate vNbDeCol as vListRef.$columns ;; ::: Un coup c'est 80, l'autre c'est 0 !!!
40 Calculate vNbDeCol as pNbDeCols
41 Do vListRef.$columns.$assign(vNbDeCol+1)
42
43 Do vBut1Ref.$gridcolumn.$assign(vNbDeCol+1)
44 Do vField1Ref.$gridcolumn.$assign(vNbDeCol+1)
45
46 Do vBut2Ref.$gridcolumn.$assign(vCol1)
47 Do vField2Ref.$gridcolumn.$assign(vCol1)
48
49 Do vBut1Ref.$gridcolumn.$assign(vCol2)
50 Do vField1Ref.$gridcolumn.$assign(vCol2)
51
52 Do vListRef.$columns.$assign(vNbDeCol)
53
54 If (vCol1>1)
55 Set reference vItem to vListRef.$dividers.[vCol1-1]
56 Calculate vDiv1Ref.$posn as vItem.$posn+vPos1Div
57 Else
58 Calculate vDiv1Ref.$posn as vPos1Div
59 End If
60
61 Set reference vItem to vListRef.$dividers.[vCol2-1]
62 Calculate vDiv2Ref.$posn as vPos2Div+vItem.$posn
63
64 Quit method kTrue
No method errors found
More information about the omnisdev-en
mailing list