Bendrinti naudojant


AxBoundField

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

An AxBoundField component displays a single value in a form or grid. The data for the field comes from the AxDataSource linked to the form or grid. You will use the Bound Field Designer to select and set the properties of the bound fields you want to use. This designer is accessed through the Fields property of the AxGroup component or the Columns property of the AxGridView component.

Properties

You can edit the properties for an AxBoundField in the following places:

  • When choosing the fields to display for an AxGridView.

  • When choosing the fields to display for an AxHierarchicalGridView.

  • When choosing the fields to display for an AxHierarchicalGanttView.

  • When choosing the collection of fields for an AxGroup.

The AxBoundField component has the following properties:

Accessibility

Property

Description

AccessibleHeaderText

A string that specifies the abbreviated text read by screen reading software.

Appearance

Property

Description

FooterText

Specifies the string that is displayed in the footer item for the field.

HeaderImageUrl

Specifies the fully qualified or relative URL to an image that is displayed in the header item for the field. The specified image will appear in place of the header text.

HeaderText

When the bound field is used in a grid, specifies the text displayed in the header item for the field. When the bound field is used in a form, specifies the text displayed for the field prompt. If no string is specified, the label for the field in the underlying table is displayed.

MaxDateLabel

Specifies the text to use for the maximum DateTime value for a date-effective field.

Behavior

Property

Description

ApplyFormatInEditMode

Specifies whether the data should be shown with the DataFormatString formatting applied when in edit mode.

AutoPostBack

Indicates whether the field is updated when a postback occurs.

ConvertEmptyStringToNull

When set to true, the field will return null if the value of the field is the empty string.

HtmlEncode

Specifies whether the field is HTML encoded when it is displayed to the user.

HtmlEncodeFormatString

Specifies whether formatted text should be HTML encoded when it is displayed.

InsertVisible

Specifies whether the field is shown when the form or grid is in insert mode.

LookupButtonDisplaySettings

Specifies when the lookup button for the field is displayed. The value can be one of the following:

Auto - Shown when a lookup has been defined

Always - Always shown

Never - Never shown

LookupCacheScope

Specifies how the content for the lookup is cached. The value can be one of the following:

None

DataBindingContainer – Cached at the datasource level, so the lookup value will be the same within the page.

Global – Cached at the company level, so the lookup value will be the same for any Enterprise Portal page.

Custom

Mandatory

Specifies whether a value is required for the field.

NullDisplayText

Specifies the text to display for the field when the field value is null. The default value is the empty string.

ReadOnly

When set to true, the value of the bound field cannot be edited.

ShowHeader

When used in a grid, specifies whether the header is shown for the field. When used in a form, specifies whether the prompt is shown for the field.

SortExpression

The sort expression that is used by the field to sort data.

Visible

Specifies whether the field is shown.

Data

Property

Description

DataField

The field in the data source to which this field is bound.

DataFormatString

The formatting that is applied to the bound value. For example, "{0:d}" or "{0:c}".

Layout

Property

Description

FastTabSummary

Specifies whether to show the field value on the summary portion of the header for an AxSection. The value Auto indicates that the field will be shown in the summary if the field is part of the AutoSummary group for the table, or if the field is part of the summary group that is defined for the AxSection.

Lookup

Property

Description

LookupPageSize

Specifies the number of items to display in the lookup.

LookupStyle

Specifies when the data for the lookup will be loaded. The value can be one of the following:

OnDemand – Data for the lookup is loaded when the user displays the lookup

PreLoad – Data for the lookup is loaded when the page is loaded

Styles

Property

Description

ControlStyle

The style applied to the control.

FooterStyle

The style applied to the footer.

HeaderStyle

The style applied to the header.

ItemStyle

The style applied to the item.

Events

The AxBoundField component has the events listed in the following table.

Event

Description

DataChanged

Occurs when the data in the field has changed.

FormattingValue

Occurs when the data in the field is formatted.

Lookup

Occurs when the lookup for the field is clicked.

Accessing Bound Field Values

When an AxBoundField object is used in a component like an AxForm, you cannot access the value of the bound field through that component. Instead, you must access the bound field value through the current row of the AxDataSource component for the User Control. For examples of accessing bound field values from an AxDataSource component, see Working with Data for Enterprise Portal.

Accessing Bound Field Properties

To access the properties for an AxBoundField, you must examine the bound field collection for the component. The following function will retrieve a specific bound field from a collection of bound fields for a component. It is better to retrieve an AxBoundField object based on its name, instead of its index.

static AxBoundField GetField(DataControlFieldCollection fields, string name)
{
    foreach (DataControlField field in fields)
    {
        // Is this the field being searched for?
        AxBoundField boundField = field as AxBoundField;
        if (boundField != null && String.Compare(boundField.DataField, name, true) == 0)
        {
            return boundField;
        }

    }
    // Nothing found, so return null.
    return null;
}

The following example uses the method created in the previous example to set the ReadOnly property for the WorkOrderNum bound field in the RequestDetailsLeft AxGroup object for an AxForm.

AxBoundField WorkOrderNumField;
WorkOrderNumField = GetField(RequestDetailsLeft.Fields, "WorkOrderNum");
WorkOrderNumField.ReadOnly = true;

Lookups for Bound Fields

When enough information is available to create one, a bound field will automatically have a lookup. For example, if the bound field is based on an extended data type, the EDT information will be used to define the content of the lookup.

You may want to use a custom lookup for the bound field, instead of the lookup that is created automatically. The content of a custom lookup for a bound field can be defined by a User Control that has been added to the AOT. You can add a LookupContentTemplate element to the markup for the AxBoundField component to specify the User Control that defines the content of the lookup. The following example shows the LookupContentTemplate element specifying that the WorkOrderList User Control will be used to define the lookup for the WorkOrderNum field.

<dynamics:AxBoundField DataField="WorkOrderNum" DataSet="FCMWorkOrderAddEdit" DataSetView="FCMWorkOrders" SortExpression="WorkOrderNum">
    <LookupContentTemplate>
        <dynamics:AxContentPanel ID="AxContentPanel1" runat="server" ManagedContentItem="WorkOrderList" />
    </LookupContentTemplate>
</dynamics:AxBoundField>

For more information about how to create custom lookups based on User Controls, see Lookups.