Hi
I have the problem that a floating label for dropdown fields float when the form is opened even it is not possible to have an empty value. The layout type is:
LayoutOptions = LayoutType.TextInputLayout
How can I remove the animation for floating labels on certain fields, e.g. dropdown?
Kind Regards,
Bruno
Hi
Many thanks for the answer and example. I attached a short video to show the behaviour in the dataform with floating labels. The effect is visible on Android and iOS virtual as well as of physical devices like Samsung S10.
I hope it helps to better understand the problem.
Regards,
Bruno
|
dataForm.RegisterEditor("DropDown", new CustomDropDownEditor(dataForm));
dataForm.RegisterEditor("Country", "DropDown");
…
…
…
public class CustomDropDownEditor : DataFormDropDownEditor {
public CustomDropDownEditor(SfDataForm dataForm) : base(dataForm)
{
}
protected override void OnInitializeView(DataFormItem dataFormItem, SfComboBox view)
{
base.OnInitializeView(dataFormItem, view);
(view.Parent.Parent.Parent as SfTextInputLayout).IsHintAlwaysFloated = true;
}
} |
Hi SaiGanesh
Many thanks for the help. I implemented the proposed solution and it works so far for all read only field in the dataform. Unfortunately, the other drop down filed has no floating label anymore (see attached print screen). I tried to define the custom editor for the one drop down only but I get a null pointer exception.
How can I archive having only one drop down without floating label?
Many thanks
Bruno
|
public class CustomDropDownEditor : DataFormDropDownEditor
{
public CustomDropDownEditor(SfDataForm dataForm) : base(dataForm)
{
}
protected override void OnInitializeView(DataFormItem dataFormItem, SfComboBox view)
{
base.OnInitializeView(dataFormItem, view);
if (dataFormItem.LayoutOptions == LayoutType.TextInputLayout)
{
(view.Parent.Parent.Parent as SfTextInputLayout).IsHintAlwaysFloated = true;
}
}
} |
Hi SaiGanesh
Many thanks for the replay. I have found a solution for the dropdown field which has always a value set.
if (dataFormItem.LayoutOptions == LayoutType.TextInputLayout && (dataFormItem.Name == "EventTypeCUID"))
{
(view.Parent.Parent.Parent as SfTextInputLayout).IsHintAlwaysFloated = true;
}
Unfortunately, I'm not able to stop the floating label for a dropdown which has a value but is not mandatory (might be empty). I would like to have the floating label when no value is set and not a floating label like above when a value has been set. Do you have an idea how to archive this behaviour?
Many thanks,
Bruno
|
private void DataForm_AutoGeneratingDataFormItem(object sender, AutoGeneratingDataFormItemEventArgs e)
{
if (e.DataFormItem != null)
{
if (e.DataFormItem.Name == "Country")
{
(e.DataFormItem as DataFormDropDownItem).DisplayMemberPath = "Name";
(e.DataFormItem as DataFormDropDownItem).SelectedValuePath = "Name";
if ((dataForm.DataObject as Address).Country == null)
{
(e.DataFormItem as DataFormDropDownItem).ShowLabel = true;
}
else
{
(e.DataFormItem as DataFormDropDownItem).ShowLabel = false;
}
}
if (e.DataFormItem.Name == "Country1")
{
(e.DataFormItem as DataFormDropDownItem).DisplayMemberPath = "Name";
(e.DataFormItem as DataFormDropDownItem).SelectedValuePath = "Name";
(e.DataFormItem as DataFormDropDownItem).LayoutOptions = LayoutType.Default;
}
}
}
public class CustomDropDownEditor : DataFormDropDownEditor
{
private DataFormItem dataFormItem;
public CustomDropDownEditor(SfDataForm dataForm) : base(dataForm)
{
}
protected override void OnInitializeView(DataFormItem dataFormItem, SfComboBox view)
{
base.OnInitializeView(dataFormItem, view);
if (dataFormItem.LayoutOptions == LayoutType.TextInputLayout)
{
this.dataFormItem = dataFormItem;
(view.Parent.Parent.Parent as SfTextInputLayout).IsHintAlwaysFloated = true;
view.SelectionChanged += View_SelectionChanged;
view.ShowClearButton = true;
}
}
private void View_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((sender as SfComboBox).Parent.Parent.Parent is SfTextInputLayout)
{
if (((sender as SfComboBox).SelectedValue != null && this.dataFormItem.ShowLabel == true) || ((sender as SfComboBox).SelectedValue == null && this.dataFormItem.ShowLabel == false))
{
this.DataForm.RefreshLayout(true);
}
}
}
} |