The requested page is not available for the requested platform. You are viewing the content for Default platform.

Access Mobile Editor Settings

  • 3 min to read

This topic demonstrates how to access editors in a Detail View using a View Controller. This Controller searches the Contact Detail View for an Anniversary Property Editor that binds data to a control. Then, the Controller sets the control's placeholder to "N/A" to bring the unspecified Anniversary property to the user's attention. The "N/A" text is displayed when the Detail View is in the Edit Mode (DetailView.ViewEditMode).

To see the code demonstrated in this topic, access the MainDemo.Module.Mobile | Controllers folder and open the MobileNullTextEditorController.cs (MobileNullTextEditorController.vb) file. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 18.2\Components\eXpressApp Framework\MainDemo by default. The Mobile version is also available online.

The following code demonstrates the MobileNullTextEditorController:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Mobile.Editors;
using DevExpress.ExpressApp.Mobile.MobileModel;
using DevExpress.ExpressApp.Utils;
// ...
public partial class MobileNullTextEditorController : ViewController {
    public MobileNullTextEditorController() {
        InitializeComponent();
        RegisterActions(components);
    }
    private void InitNullText(MobilePropertyEditor propertyEditor) {
        if(propertyEditor.ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit) {
            ((DateBox)propertyEditor.Control)["inputAttr"] = new Dictionary<string, object> {
                { "placeholder", CaptionHelper.NullValueText }
            };
        }
    }
    private void propertyEditor_ControlCreated(object sender, EventArgs e) {
        InitNullText((MobilePropertyEditor)sender);
    }
    protected override void OnActivated() {
        base.OnActivated();
        MobilePropertyEditor propertyEditor = 
((DetailView)View).FindItem("Anniversary") as MobilePropertyEditor;
        if(propertyEditor != null) {
            if(propertyEditor.Control != null) {
                InitNullText(propertyEditor);
            }
            else {
                propertyEditor.ControlCreated += new EventHandler<EventArgs>(propertyEditor_ControlCreated);
            }
        }
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        ViewItem propertyEditor = ((DetailView)View).FindItem("Anniversary");
        if(propertyEditor != null) {
            propertyEditor.ControlCreated -= new EventHandler<EventArgs>(propertyEditor_ControlCreated);
        }
    }
}

Note that the MobileNullTextEditorController uses the CaptionHelper.NullValueText property to get a localized "N/A" text.

Run the Mobile application and open the Contact Detail View. The Anniversary editor shows the "N/A" text if the editor's value is unspecified.

MobileNullTextEditorController

See Also