uniGUI trial notes (11) ---UNIDBGRID

I recently studied UniGUI's TuniDBGrid and recorded it so as not to forget it.

Important properties of TuniDBGrid include:

1. Columns - TUniDBGridColumns and TUniDBGridColumn

Important properties of each column object (TUniDBGridColumn) include:

  • CheckBoxField : TUniCheckBoxField

Columns as relevant properties for CheckBox actions

Attributes

Types of

illustrate

AutoPost

Boolean

When the user clicks the CheckBox, change the front-end display and decide according to this property:

True - automatically commit to the dataset immediately and refresh the front-end display

False—Only change the front-end display, and submit the dataset when the record scrolls

BooleanFieldOnly

Boolean

Is it only for Boolean fields,

True - only Boolean fields can be recognized, non-Boolean fields will not be able to display CheckBox

False—DisplayValues ​​and FieldValues ​​can be handled for non-Boolean fields

Enabled

Boolean

Whether to allow the CheckBox to be displayed

DisplayValues/

FieldValues

string

The joint determines the corresponding values ​​of the CheckBox in different states. FieldValues ​​stores the field value, and DisplayValues ​​stores the displayed text. If it is blank, it means that the text is not displayed, only the CheckBox is displayed. Each value is distinguished by a semicolon (;), and the text is displayed on the right side of the CheckBox. . As shown below:

image

  • DisplayMemo:Boolean

For TMemoField, whether to display the word (Memo), the default is False

False—Do not display the field content, display the word (Memo)

True—do not display the word (Memo), but directly display the field content

  • Filtering : TUniColumnFilter

The filter edit box is displayed under the column header, and the column data is automatically filtered, as shown in the following figure:

image

Refer to the GridFilter example under Demos. To implement this feature, you must:

     A. Put a TUniHiddenPanel control on the form, and then place TUniEdit, TUniComboBox, TUniDBLookupComboBox and other controls on this hidden Panel, as shown below:

image

      B. Set the Filtering of each column, and set its Editor property to the corresponding edit control

      C. Set relevant properties for the edit control, such as TUniDBLookupComboBox needs to set ListSource, etc.

Attributes

Types of

illustrate

ChangeDelay

Integer

The number of milliseconds to delay filtering after the user types a character

Editor

TControl

Filtered input box, filter according to the content of the input box. TUniDBLookupComboBox is filtered by the value of KeyField

Enabled

Boolean

whether to allow filtering

  • GroupHeader 和 GroupHeaderSeparator

Display headers in multiple columns, for example, the style when GroupHeader = a;b;c is shown in the following figure:

image

  • ShowSummary:Boolean

Whether to display the total value, used in conjunction with the Grid's Summary property.

  • Sortable:Boolean

Whether to allow sorting operations. When the sorting operation is enabled, the sorting symbol is displayed next to the field name, and the sorting menu in the Menu is available, as shown in the following figure:

image

  • Editor : TControl;

When editing the field, what kind of control the corresponding unit uses to process, this function is very powerful. For example, setting TuniComboBox as Editor will completely replace the function of field Picklist, as shown in the following figure:

image

  • Memu (TUniColumnMenu)

Controls the menu displayed by the column header drop-down

Attributes

Types of

illustrate

ColoumnHideable

Boolean

Whether to allow hidden fields, the default is True, which allows the user to hide the specified column by checking, as shown below:

image

MenuEnabled

Boolean

Whether to allow menus to be displayed for columns

MenuText

String

The text displayed on the menu in this column is empty by default, which means the field DisplayLabel is displayed, otherwise the text is displayed. As shown below:

image

  • ImageOptions

When the field needs to display an image, use the ImageOptions property in conjunction with the OnFieldImage event, where:

Attributes

Types of

illustrate

Height/Width

Integer

Display image size

Visible

Boolean

Whether to display the image, True triggers the OnFieldImage event for image processing, such as:

procedure TMainForm.UniDBGrid1FieldImage(const Column: TUniDBGridColumn;

const AField: TField; var OutImage: TGraphic; var DoNotDispose: Boolean;

var ATransparent: TUniTransparentOption);

begin

if SameText(AField.FieldName, 'gender') then

begin

// code to process the image

DoNotDispose := True;

// return image based on field value

if AField.AsString = 'male' then

OutImage := UniImage1.Picture.Graphic

else if AField.AsString = 'female' then

OutImage := UniImage2.Picture.Graphic;

end;

end;

This method allows the column to display an image button, such as:

image

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325453914&siteId=291194637