Jump to content
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr ×
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr

[DocWiki 번역] 동적 필드 컴포넌트(들)


Recommended Posts

Docwiki에 있는 "Dynamic Field Components"를 번역한 글 (번역일: 2022년 3월 7일)

위로 가기: Working with Field Components Index

Dynamically generated field components are the default. In fact, all field components for any dataset start out as dynamic fields the first time you place a dataset on a data module, specify how that dataset fetches its data, and open it. A field component is dynamic if it is created automatically based on the underlying physical characteristics of the data represented by a dataset. Datasets generate one field component for each column in the underlying data. The exact Data.DB.TField descendant created for each column is determined by field type information received from the database or (for TClientDataSet) from a provider component.

필드 컴포넌트(들)은 동적으로 생성되는 것이 기본 설정이다. 실제로, 데이터 모듈 위에 데이터셋을 처음 올려 놓고, 데이터셋 안에 있는 데이터를 가져오는 방식을 명시하고, 데이터셋을 오픈하면, 해당 데이터셋 안에는 해당되는 모든 필드 컴포넌트(들)이 생성된다. "동적(dynamic)" 필드 컴포넌트라고 함음 데이터셋의 밑바탕에 있는 물리적 데이터의 특성으로 그대로 자동으로 반영하는 데이터셋의 필드를 말한다. 동적 필드는 Data.DB.TField의 직계 후손이며, 각 컬럼 타입은 해당 데이터베이스 또는 (TClientDataSet인 경우에는) 프로바이더(Provider) 컴포넌트에서 받아온 필드 타입 정보에 의해서 그대로 결정된다. 

Dynamic fields are temporary. They exist only as long as a dataset is open. Each time you reopen a dataset that uses dynamic fields, it rebuilds a completely new set of dynamic field components based on the current structure of the data underlying the dataset. If the columns in the underlying data change, then the next time you open a dataset that uses dynamic field components, the automatically generated field components are also changed to match.

동적 필드(Dynamic Field)는 영속 필드(Persistent Field)가 아니다. 따라서 동적 필드는 해당 데이터셋이 오픈(Open) 되어 있는 동안에만 존재한다. 동적 필드를 사용하는 데이터셋은 오픈(Open)될 때 마다 밑바탕에 있는 데이터베이스의 당시 구조를 기반으로하여 무조건 해당 데이터셋의 동적 필드 컴포넌트(들)을 완전히 새로 만든다. 만약 밑바탕 데이터에서 컬럼이 변경되었다면, 동적 필드 컴포넌트(들)을 사용하는 데이터셋이 다음에 다시 오픈될 때에는, 자동으로 필드(들)이 다시 생성되므로 변경된 밑바탕 데이터베이스에 일치하게 된다.

Use dynamic fields in applications that must be flexible about data display and editing. For example, to create a database browsing tool you must use dynamic fields because every database table has different numbers and types of columns. You might also want to use dynamic fields in applications where user interaction with data mostly takes place inside grid components and you know that the datasets used by the application change frequently.

애플리케이션의 데이터 표현과 편집이 유연해야 한다면 동적 필드를 사용하라. 예를 들어 데이터베이스를 탐색하는 도구를 만든다면 반드시 동적 필드를 사용해야한다. 그 이유는 데이터베이스 안에 있는 테이블의 숫자와 컬럼 타입이 변할 텐데 그런 변화를 반영해야 하기 때문이다. 또한 애플리케이션 사용자가 데이터 작업을 할 때 주로 그리드 컴포넌트 안에서 사용하며, 그리드 안에 있는 데이터셋이 수시로 바뀔 것이라는 점을 미리 알고 있을 때에도 동적 필드가 적합하다.

To use dynamic fields in an application

  1. Place datasets and data sources in a data module.
  2. Associate the datasets with data. This involves using a connection component or provider to connect to the source of the data and setting any properties that specify what data the dataset represents.
  3. Associate the data sources with the datasets.
  4. Place data-aware controls in the application's forms, add the data module to each uses clause for each form's unit, and associate each data-aware control with a data source in the module. In addition, associate a field with each data-aware control that requires one. Note that because you are using dynamic field components, there is no guarantee that any field name you specify will exist when the dataset is opened.
  5. Open the datasets.

동적 필드 (Dynamic Field)를 애플리케이션에서 사용하는 방법

  1. 데이터 모듈(Data Module)에 데이터셋(Dataset)과 데이터 소스(Data source)를 올려놓는다.
  2. 올려둔 데이터셋을 물리적 데이터와 연결한다. Connection 컴포넌트 또는 프로바이더(Provider)를 사용하여 데이터 소스에 연결하고 데이터셋이 나타내는 데이터를 명시하는 프로퍼티(들)을 설정한다.
  3. 애플리케이션의 폼 안에 데이터-인식(data-aware) 컨트롤을 올려놓고, 해당 폼의 uses 절에는 앞에서 작업한 데이터 모듈을 추가한다. 그리고 나서, 폼 위에 있는 데이터-인식 컨트롤을 데이터 모듈에 있는 데이터 소스와 연결한다. 데이터-인식 컨트롤과 그것이 사용할 데이터 필드를 연결하는 작업을 부가적으로 진행할 수도 있다. 단, 동적 필드 컴포넌트를 사용하는 경우에는  개발자가 명시한 필드 이름이 해당 데이터셋이 오픈(Open)되는 시점에 실재로 존재할 것이라는 보장이 없다는 점을 주의해야 한다.      
  4. 데이터셋을 오픈(Open) 한다.

Aside from ease of use, dynamic fields can be limiting. Without writing code, you cannot change the display and editing defaults for dynamic fields, you cannot safely change the order in which dynamic fields are displayed, and you cannot prevent access to any fields in the dataset. You cannot create additional fields for the dataset, such as calculated fields or lookup fields, and you cannot override a dynamic field's default data type. To gain control and flexibility over fields in your database applications, you need to invoke the Fields editor to create persistent field components for your datasets.

사용하기 쉬운 한편, 동적 필드에는 제약이 있다. 코드를 작성하지 않기 때문에, 동적 필드가 표시되고 편집되는 기본 설정을 변경할 수 없다. 동적 필드가 표시되는 순서를 안전하게 바꿀 수 없으며 데이터셋에 있는 필드들 중 원하지 않는 필드에 접근하는 것을 방지하지 못한다. 데이터베이스 애플리케이션에서 자유자재로 필드을 통제하고 싶다면 필드 에디터 (Fields Editor) 창을 열고 데이터셋 안에 영속 필드(Persistent Field) 컴포넌트를 넣어야 한다.


기타 참고 (See Also)

[DocWiki 번역] 영속 필드(Persistent Field) 컴포넌트(들)
Working with Field Component Methods at Runtime
Displaying, Converting, and Accessing Field Values
Setting a Default Value for a Field
Working with Constraint
Using Object Fields

이 댓글 링크
다른 사이트에 공유하기

이 토의에 참여하세요

지금 바로 의견을 남길 수 있습니다. 그리고 나서 가입해도 됩니다. 이미 회원이라면, 지금 로그인하고 본인 계정으로 의견을 남기세요.

Guest
이 토픽(기고/질문)에 답하기

×   서식있는 텍스트로 붙여넣기.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   이전에 작성한 콘텐츠가 복원되었습니다..   편집창 비우기

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

중요한 정보

이용약관 개인정보보호정책 이용규칙 이 사이트가 더 잘 작동하기 위해 방문자의 컴퓨터에 쿠키가 배치됩니다. 쿠키 설정 변경에서 원하는 설정을 할 수 있습니다. 변경하지 않으면 쿠키를 허용하는 것으로 이해합니다.