You can define ATTRIBUTES and/or MASKS for the fields that will be displayed in the GRID without adding a line of code and without adding the fields in the FIELDS EDITOR of the respective query.


Example without frmBaseCRUD inheritance


See frmFISHFACT to apply the necessary functions:


- dbgFishDrawColumnCell event

- UniFrameCreate event

- UniFrameReady event


Example inherited from frmBaseCRUD


Define your attributes in your uniDBGRID's HINT property or even in your form's OnCreate event as in the example below extracted from "frmCadCLIENTES":


  dbgSearchCRUD.Hint := '[[' +

                        'fieldmasks:' +

                        //'no-paged|' +

                        //'grid-noforcefit|' +

                        'grid-forcefit:10 mobile-v-5 mobile-h-8|' + // v. 4.0.0.0

                        'model-crud:1|' +

                        'grid-resize|' +

                        'firstshow:0|'+  // v. 3.2.0.2

                        'grid-paginator:center|' + // v. 4.0.0.0

                        'código[[' +

                        //'   locked|' +

                        '   title:translate(codigo)|' +

                        '   titlealign:c|' +

                        '   align:c|' +

                        '   width:135 mobile:90]];' +

                        // v. 4.0.0.0

                        // [PT]

                        // alguns campos com strings muito grandes são interpretados pelo unigui como MEMO e não

                        // sao exibidos, este atributo força a exibição do texto

                        // [EN]

                        // some fields with very large strings are interpreted by unigui as MEMO and not

                        // are displayed, this attribute forces the text to be displayed

                        //'memotest[[' +

                        //'   displaymemo|]];' +


                        'nome[[' +

                        '   title:translate(nome)]];' +


                        'email[[' +

                        '     visible:false mobile]];' +


                        'endereco[[' +

                        '     visible:false mobile]];' +


                        'numero[[' +

                        '   visible:false mobile|' +

                        '   align:r]];' +


                        'complemento[[' +

                        '     visible:false]];' +


                        'cidade[[' +

                        '     visible:false mobile]];' +


                        'uf[[' +

                        '     visible:false mobile]];' +


                        'fone1[[' +

                        '     visible:false mobile]];' +


                        'cnpj_cpf[[' +

                        '     visible:false mobile]];' +

                        // v. 4.0.0.0

                        'dtcadastro[[' +

                        '     visible:false]];' +

                        'dtaniversario[[' +

                        '     visible:false]];' +


                        'cep[['+

                        '   visible:false mobile|' +

                        '   align:c|'+

                        '   mask:' + mm.varC_Mask_cep + ']];' +


                        'valor_contrato[[' +

                        '   visible:false mobile|' +

                        '   cls:{<130,color-red,color-black}|'+

                        '   mask:' + PFmtSettings.CurrencyString + ' ' + mm.varC_Mask_float + ']]; ' +


                        'limitecredito[[' +

                        '   visible:false mobile|' +

                        '   cls:color-blue]];' +


                        ']]';



   Format: field[[attr:value|attr:value...]];


       obs: 'field' must comply with your SELECT. If there is an ALIAS, inform the ALIAS.


fieldmasks:        - indicates the beginning of attributes

no-paged:          - disables the pager

grid-paginator:    - disables the default bar and adds the new RadCORE bar.


   Note: During rendering, the grid will be resized to the size of its "parent".

         The ideal is to put your grid in a responsive block.


grid-noforcefit:   - does not apply "forcefit"

grid-forcefit:         - Activate forcefit according to configured parameters


   Ex: grid-forcefit:13 mobile-v-5 mobile-h-8

   Apply forcefit if there are 13 columns or less and not in MOBILE.

   Apply forcefit if there are 5 columns or less and it is in MOBILE VERTICAL.

   Apply forcefit if there are 8 columns or less and you are in MOBILE HORIZONTAL.


   Note: forcefit does not work well in conjunction with LOCKED


model-crud:0       - is the default and is optional, but when specified it is possible to customize the template. renders template no. 0 for CRUD layout( Ex: frmCadFORNECEDOR / frmCadFUNCIONARIO )

model-crud:1       - renders model no. 1 for CRUD layout( Ex: frmCadCLIENTES )

model-crud:2       - renders model no. 2 for CRUD layout( Ex: frmCadCIDADES )

model-crud:3       - renders model no. 1 for CRUD layout( Ex: frmCadFERIADOS )


grid-resize:       - rearrange the grid if the user rotates the device, for example

firstshow:NN       - When accessing the form for the first time, only NN records will be loaded


locked                 - lock column


            title:AAAAAAAA         - defines a title for the field in the grid

title:translate(fn)- set runtime translation for indicated column


            charcase:                 - define a CHAR CASE for the field in the grid


                     variations:


charcase:u          - converts to uppercase letters

charcase:l         - converts to lowercase letters 


            width:NN           - defines a WIDTH for the field in the grid


                     variations:


width:20 mobile:45

width:20 mobile-h:45 mobile-v:88

                       width:4% mobile-h:8% mobile-v:12%


                       Adjusts the column width according to the device. When used, "%" will be calculated by the width of the GRID.



            mask:#,#0.00##        - defines a MASK for the field in the grid


            align:                - defines an alignment for the field in the grid


                     variations:


align:l - align to the left

align:c - align to the center

align:r - align to the right


titlealign:                - defines an alignment for the column title in the grid


variations:


titlealign:l - align to the left

titlealign:c - align to the center

titlealign:r - align to the right


            visible:false      - hide the column


                     variations:


                       visible:false mobile        - hides the column when accessing the application in MOBILE

visible:false mobile-v        - hides the column when accessing the application in MOBILE PORTRAIT

                       visible:false mobile-h        - hides the column when accessing the application in MOBILE LANDSCAPE


There is a problem that has not yet been resolved (understood): On the example screen ( frmCadCOMPRAS ) the visible was

replaced by "width" as it throws an internal exception in JS.


            cls:color-blue     - apply a css class


            cls:{<0,color-red,color-black} - apply a conditional css class


                       the column must be numeric. Therefore, if the value is less than '0', the class "color-red", if not, "color-black" is applied.


Nota:

    Although the feature is very interesting, dynamic attributes require more processing.

    On desktop it is acceptable but on MOBILE, performance is very compromised.

    You can choose not to use it.


Note

You can use RC ELEMENTs or via code, feed the HINT property (as in the examples above). When there are many configurations it is more practical to use via code.


Columns with dynamic action buttons


For more details, see the example in frmCadFERIADOS and frmBaseCRUD (which interprets part of the information defined in its inherited forms).


These settings are only to demonstrate the RadCORE feature and not just to perform CRUD actions.


You can create any type of ACTION BUTTON and its properties, just remember to add the respective EVENT in your CellClick [gridname] of your form.



[[grid-btn: edo]]                - Creates the standard buttons: EDIT, DELETE and OPTIONS. The events are already configured to trigger the respective buttons


[[grid-btn: (edit)]]                - Creates the default button: EDIT with the default settings.

[[grid-btn: (delete)]]        - Creates the default button: DELETE with the default settings.

[[grid-btn: (options)]]        - Creates the default button: OPTIONS with the default settings.


For more details, see the example on frmCadFERIADOS (on Create).




IMPORTANT: 

When an action button is detected in the form inherited from "frmBaseCRUD", the CRUD model is also changed according to the image above.

The intention, in addition to demonstrating the feature, is to give you more options for you to apply to your projects.


IMPORTANT:

Looking at the code it is possible to add more criticisms. These features are rendered in the rc_GridDrawCell function that is called in the OnDrawColumnCell event

of your uniDBGrid.


IMPORTANT: as of version 2.0.0.154, the declaration of the variable "varC_FieldMasks" is no longer needed in the OnCreate event of your form. It is necessary that you adjust your settings for the HINT of the respective GRID.

Created with the Personal Edition of HelpNDoc: Qt Help documentation made easy