Wednesday, 3 July 2013

Accessing (AXBound) Bound Field Properties

///

    /// Code to get Field from Grid. Mallik
    ///

    ///
    ///
    ///
    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 above to set the ReadOnly property for the SalesQty bound field in the AxGridView1  grid object for an AxForm.
-------------------------------------------------------------------------------------------------------------------------
AxBoundField RelatedSalesQty;
        AxBoundField RelatedSalesUnit;
        try
        {
            row = this.GetCurrentRow;
            authorizationStatus = row.GetFieldValue("AvaAuthorizationStatus").ToString();
            if (authorizationStatus == "0")//Labels.GetLabel("@AVA114"))
            {
                AxGridView1.AllowEdit = true;
                AxGridView1.AllowDelete = true;
                AxGridView1.AutoGenerateEditButton = true;
               
                RelatedSalesQty = GetField(AxGridView1.Columns, "SalesQty");
                RelatedSalesQty.ReadOnly = false;
                RelatedSalesUnit = GetField(AxGridView1.Columns, "SalesUnit");
                RelatedSalesUnit.ReadOnly = false;
                //AxGridView1.Columns.Contains("SalesQty")
                ret = true;
            }

No comments:

How to Disable “Advanced Filter or Sort” and Enforce Custom Filters on Any D365FO Form

 In Dynamics 365 Finance and Operations, users can apply filters through the “Advanced filter or sort” feature found under the Options tab...