Page 1 of 1

block cells in a grid at runtime

Posted: Wed Dec 12, 2012 2:22 pm
by luisvasquezcl
Hola a todos,
La función indicada a continuación permite bloquear o desbloquear una celda ( o las que quiera ) de un grid para su edición.
Normalmente podemos bloquear la edición de las celdas en tiempo de diseño completando la propiedad ColumnWhen.
Con este procedimiento obtengo el array que contiene la definicion de la propiedad ColumnWhen del grid y simplemente cambio el bloque de código definido para la columna de acuerdo a la condición que se desee.
Para que funcione el bloqueo antes de que se edite yo lo puse en el evento On Change del Grid por lo tanto cada vez que navego por las filas del grid me cambia el estado automáticamente de acuerdo a la condición que espero se cumpla.

En este ejemplo tengo un grid con 3 datos que son Id, Rut, Nombre. y verifico que si la celda ID está en 0 el usuario puede ingresar datos en la celda Rut en caso contrario no permite hacerlo, solo la celda Nombre.

static procedure lock_cell
local i := GetControlIndex ( "grid_1" , "Form_1" )
_HMG_SYSDATA[ 40 ] [ i ] [ 6 ] [ 2 ] := if( form_1.grid_1.cell(form_1.grid_1.value,1 ) <> 0, { || .f. } , { || .t. } )
return

Espero les sea de utilidad
Saludos cordiales,
Luis Vasquez

English By Google Translator

Hi all,
The function shown below to lock or unlock a cell (or want) a grid for editing.
Normally we can block cell editing at design time completing ColumnWhen property.
With this procedure I get an array that contains the definition of the grid ColumnWhen property and simply change the code block defined for the column according to the desired condition.
To operate the lock releases before I put it in the Grid On Change event so every time I browse the rows of the grid changes my status automatically according to the condition that hope is fulfilled.

In this example I have a grid with 3 data are Id, Ruth, Name. and verify that if the cell ID is 0 the user can enter data in cell Rut otherwise not allowed to do so, only the cell name.

static procedure lock_cell
local i := GetControlIndex ( "grid_1" , "Form_1" )
_HMG_SYSDATA[ 40 ] [ i ] [ 6 ] [ 2 ] := if( form_1.grid_1.cell(form_1.grid_1.value,1 ) <> 0, { || .f. } , { || .t. } )
return


I hope this will be useful
Best regards,
Luis Vasquez

Re: block cells in a grid at runtime

Posted: Wed Dec 12, 2012 3:57 pm
by Pablo César
Gracias Luis por compartir con nosotros. Muy buena solucion !

Re: block cells in a grid at runtime

Posted: Wed Dec 12, 2012 4:08 pm
by Rathinagiri
Thanks a lot!

Re: block cells in a grid at runtime

Posted: Thu Dec 13, 2012 12:15 pm
by srvet_claudio
Hola Luis.
Podés cambiar en tiempo de ejecución cualquier control de edición de un Grid con GridEx de la librería HFCL.

Code: Select all

// FUNCTIONS
**********************************************************************************
* GRID_ColumnCount         ---> Return the Number of Column on GRID
*
* GRID_AddColumnEx         ---> Complement of Method:  AddColumn (nColIndex)
* GRID_DeleteColumnEx      ---> Complement of Method:  DeleteColumn (nColIndex)
*
* GRID_GetColumnControlsEx ---> Return Array with Controls of Column(nColIndex) ==> {cCAPTION, nWIDTH, nJUSTIFY, aCOLUMNCONTROL, bDYNAMICBACKCOLOR, bDYNAMICFORECOLOR, bCOLUMNWHEN, bCOLUMNVALID, bONHEADCLICK}
*
* GRID_GetColumnControl    ---> Return specific Control of Column(nColIndex) ==> [cCAPTION, nWIDTH, nJUSTIFY, aCOLUMNCONTROL, bDYNAMICBACKCOLOR, bDYNAMICFORECOLOR, bCOLUMNWHEN, bCOLUMNVALID, bONHEADCLICK]

* GRID_SetColumnControl    ---> Set specific Control of Column(nColIndex)    ==> [cCAPTION, nWIDTH, nJUSTIFY, aCOLUMNCONTROL, bDYNAMICBACKCOLOR, bDYNAMICFORECOLOR, bCOLUMNWHEN, bCOLUMNVALID, bONHEADCLICK]
*
* GRID_GetColumnDisplayPos ---> Get the position of Column(nColIndex) in that display in the GRID
* GRID_SetColumnDisplayPos ---> Set the position of Column(nColIndex) in that display in the GRID
*
* GRID_GetColumnWidthDisplay -> Get the Width of Column(nColIndex) in that display in the GRID
*
* GRID_SetBkImage          ---> Set background image in Grid
**********************************************************************************


// SYNTAX
**********************************************************************************
* GRID_ColumnCount (cControlName , [cParentForm])
* GRID_AddColumnEx (cControlName, [cParentForm], nColIndex, [aCOLUMNCONTROL], [bDYNAMICBACKCOLOR], [bDYNAMICFORECOLOR], [bCOLUMNWHEN], [bCOLUMNVALID], [bONHEADCLICK])
* GRID_DeleteColumnEx (cControlName, [cParentForm], nColIndex)
* GRID_GetColumnControlsEx (cControlName, [cParentForm], nColIndex)
* GRID_GetColumnControl (cControlName , [cParentForm], nControl, nColIndex)
* GRID_SetColumnControl (cControlName , [cParentForm], nControl, nColIndex, Data)
* GRID_GetColumnDisplayPos (cControlName, [cParentForm], nColIndex)
* GRID_SetColumnDisplayPos (cControlName, [cParentForm], nColIndex, nPos_Display)
* GRID_GetColumnWidthDisplay (cControlName, cParentForm, nColIndex)
* GRID_SetBkImage (cControlName, [cParentForm], nAction, cBMPFileName, yOffset, xOffset)
**********************************************************************************
Fíjate el ejemplo en C:\hmg.3.1.1\hfcl\Samples\GridEx
Un abrazo,
Claudio.

Re: block cells in a grid at runtime

Posted: Thu Dec 13, 2012 6:31 pm
by luisvasquezcl
Gracias Claudio por la aclaración.
Tendré que darle una mirada al manual ;)
Saludos cordiales,
Luis Vasquez

Re: block cells in a grid at runtime

Posted: Wed Dec 19, 2012 4:09 am
by Leopoldo Blancas
Hello

It only take a look at the sample executables that come in HFCL, and truly extraordinary, thank you for your time and dedication to Dr. Claudio HMG:!:
Greetings from Mexico
Polo


*-----------------------------------------------------------------------------------------------------------------------------
Hola

Solo le heche un vistazo a los ejecutables que vienen de ejemplo en HFCL, y en verdad extraordinarios, mil gracias por su tiempo y dedicación a HMG Dr. Claudio :!:
Saludos desde México
Polo

Re: block cells in a grid at runtime

Posted: Wed Dec 19, 2012 10:37 am
by srvet_claudio
Leopoldo Blancas wrote:Hello

It only take a look at the sample executables that come in HFCL, and truly extraordinary, thank you for your time and dedication to Dr. Claudio HMG:!:
Greetings from Mexico
Polo


*-----------------------------------------------------------------------------------------------------------------------------
Hola

Solo le heche un vistazo a los ejecutables que vienen de ejemplo en HFCL, y en verdad extraordinarios, mil gracias por su tiempo y dedicación a HMG Dr. Claudio :!:
Saludos desde México
Polo
Polo, muchas gracias.
Saludos,
Claudio.

Re: block cells in a grid at runtime

Posted: Fri Jan 18, 2013 11:15 pm
by giuper63
Many thanks Claudio,
your post helped me very much to find the column width not only in grid but also in browse columns!

Great!
Greetings.

Re: block cells in a grid at runtime

Posted: Fri Jan 18, 2013 11:31 pm
by srvet_claudio
giuper63 wrote:Many thanks Claudio,
your post helped me very much to find the column width not only in grid but also in browse columns!

Great!
Greetings.
Thanks Giuseppe.
Regards,
Claudio.