PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2025 → Modifier la valeur ordre de création d'un champ d'état
Modifier la valeur ordre de création d'un champ d'état
Iniciado por Julien V, 30,oct. 2018 15:28 - 2 respuestas
Miembro registrado
134 mensajes
Publicado el 30,octubre 2018 - 15:28
Bonjour,

Je développe actuellement un éditeur de courrier dans une de mes applications.

Pour cela j'ai un état squelette où je rends manipulable (affichage, contenu) les champs libellés, images, états internes, code-barres et signature électronique.

Au premier chargement d'un état, je boucle sur ses champs pour les proposer dans une table avec le code suivant :
// Paramètres de champs non connus, on initialise avec les champs de l'état
VariableRAZ( __parametres )
i = 1
champ = EnumèreChamp( MoiMême, i )
TANTQUE champ <> ""

// Ex. le champ LIB_sous_titre donne comme type LIB et comme libellé sous titre
( type, libelle ) = ChaîneDécoupe( champ, "_", "-" )
libelle = Remplace( libelle, "_", " " )

j = TableauAjoute( __parametres.champs )

AVEC __parametres.champs[ j ]

.nom = champ
.type = type
.libelle = libelle
SELON type
CAS "LIB" : .valeur = { champ, indChamp }..Valeur
CAS "ETATINT" : .valeur = { champ, indChamp }..NomEtatInterne
FIN // SELON type
.Visible = { champ, indChamp }..Visible

FIN // AVEC __parametres.champs[ j ]

i++
champ = EnumèreChamp( MoiMême, i )
FIN // TANTQUE champ <> ""

Le problème avec ce type d'énumération c'est que par défaut on utilise l'ordre de création des champs.
Ce qui fait qu'un champ positionné en début d'état mais créé en dernier apparaitra en fin de liste.

Cas concret : je veux réorganiser mes champs en fonction de la propriété visible avec le code suivant :
y = 0
i = 1
champ = EnumèreChamp( GR_corps, i )
TANTQUE champ <> ""
SI { champ, indChamp }..Visible ALORS
{ champ, indChamp }..Y = y
y += { champ, indChamp }..Hauteur
FIN // SI { champ, indChamp }..Visible ALORS
i++
champ = EnumèreChamp( GR_corps, i )
FIN // TANTQUE champ <> ""

Le champ LIB_sous_titre pourtant positionné en 2ème position dans mon groupe GR_corps se retrouve en dernière position.




Avec les champs d'état on ne peut pas utiliser parOrdreDeTabulation et parAltitude visuellement c'est le merdier à gérer.

Est-ce qu'il y a possibilité de modifier l'ordre de création d'un champ ?
Miembro registrado
134 mensajes
Publicado el 30,octubre 2018 - 16:00
Me réponds à moi même, j'ai une bidouille pour ce cas particulier
STChampTrie est une structure
champ est une chaîne
y est un entier
FIN // STChampTrie est une Structure

champTrie est un STChampTrie
champsTries est un tableau de 0 STChampTrie

champ = EnumèreChamp( GR_corps, i )
TANTQUE champ <> ""
VariableRAZ( champTrie )
champTrie.champ = champ
champTrie.y = { champ, indChamp }..Y
TableauAjoute( champsTries, champTrie )
i++
champ = EnumèreChamp( GR_corps, i )
FIN // TANTQUE champ <> ""
TableauTrie( champsTries, ttMembre, "y" )

POUR TOUT champTrie de champsTries
SI { champTrie.champ, indChamp }..Visible ALORS
{ champTrie.champ, indChamp }..Y = y
y += { champTrie.champ, indChamp }..Hauteur
FIN // SI c..Visible ALORS
FIN // POUR TOUT champTrie DE champsTries
Miembro registrado
134 mensajes
Publicado el 30,octubre 2018 - 16:48
Me re-réponds à moi même pour la présentation dans le tableau
STChampTrie est une structure
ordre_bloc est un entier
champ est une chaîne
x est un entier
y est un entier
FIN // STChampTrie est une Structure
champTrie est un STChampTrie
champsTries est un tableau de 0 STChampTrie

i = 1
champ = EnumèreChamp( GR_entete, i )
TANTQUE champ <> ""
VariableRAZ( champTrie )
champTrie.ordre_bloc = 1
champTrie.champ = champ
champTrie.x = { champ, indChamp }..X
champTrie.y = { champ, indChamp }..Y
TableauAjoute( champsTries, champTrie )
i++
champ = EnumèreChamp( GR_entete, i )
FIN // TANTQUE champ <> ""

i = 1
champ = EnumèreChamp( GR_corps, i )
TANTQUE champ <> ""
VariableRAZ( champTrie )
champTrie.ordre_bloc = 2
champTrie.champ = champ
champTrie.x = { champ, indChamp }..X
champTrie.y = { champ, indChamp }..Y
TableauAjoute( champsTries, champTrie )
i++
champ = EnumèreChamp( GR_corps, i )
FIN // TANTQUE champ <> ""

i = 1
champ = EnumèreChamp( GR_pied, i )
TANTQUE champ <> ""
VariableRAZ( champTrie )
champTrie.ordre_bloc = 3
champTrie.champ = champ
champTrie.x = { champ, indChamp }..X
champTrie.y = { champ, indChamp }..Y
TableauAjoute( champsTries, champTrie )
i++
champ = EnumèreChamp( GR_pied, i )
FIN // TANTQUE champ <> ""

TableauTrie( champsTries, ttMembre, "ordre_bloc;y;x" )

POUR TOUT champTrie de champsTries

// Ex. le champ LIB_sous_titre donne comme type LIB et comme libellé sous titre
( type, libelle ) = ChaîneDécoupe( champTrie.champ, "_", "-" )
libelle = Remplace( libelle, "_", " " )

j = TableauAjoute( __parametres.champs )

AVEC __parametres.champs[ j ]

.nom = champTrie.champ
.type = type
.libelle = libelle
SELON type
CAS "LIB" : .valeur = { champTrie.champ, indChamp }..Valeur
CAS "ETATINT" : .valeur = { champTrie.champ, indChamp }..NomEtatInterne
FIN // SELON type
.Visible = { champTrie.champ, indChamp }..Visible

FIN // AVEC __parametres.champs[ j ]

FIN // POUR TOUT champTrie DE champsTries