SfDataForm - CustomEditor - DropDown (Picker)

i have the following scenario.


public class SelectableObject
{
public string Name {get;set;}
public Guid Id {get;set;}
}


public ObjectToEditInEditor
{
public string Type {get;set;}
public int Quantity {get;set;}
public SelectableObject {get;set;}
}



how can i make a custom Editor to use in the DataForm to select a SelectableObject ? the custom Editor should have an input for a SelectableObject List as the source for the picker.




6 Replies

SS SaiGanesh Sakthivel Syncfusion Team May 30, 2023 01:39 PM UTC

Hi Andreas,


#Regarding how can i make a custom Editor to use in the DataForm to select a SelectableObject the custom Editor should have an input for a SelectableObject List as the source for the picker.

Your requirement can be achieved with the help of DataFormPickerEditor to select a SelectableObject, with List as source.


Code Snippet

public class SelectableObject
{
public string Name {get;set;}
public Guid Id {get;set;}
}


The example code you shared has to be changed like below

public class ObjectToEditInEditor

{

public string Type {get;set;}

public int Quantity {get;set;}

public string SelectableObject {get;set;}

}


We have documented ‘Loading the complex type property values in picker’ in our user guidance document. Please refer to the following UG documentation for your reference.

https://help.syncfusion.com/maui/dataform/editors#loading-the-complex-type-property-values-in-picker


Please refer to the demo sample in the attachment. Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel


Attachment: DataFormPicker_b2d5fb20.zip


AN Andreas June 1, 2023 09:15 PM UTC

yes but i have


public ObjectToEditInEditor
{
public string Type {get;set;}
public int Quantity {get;set;}
public SelectableObject {get;set;}
}

so a direct reference to the Object and not just a string taking a value of the object.


therfor "OnGenerateDataFormItem" is not working, since as it seem, the "e.DataFormItem.FieldName" is never "SelectableObject" but "SelectableObject.Name" and "SelectableObject.Id"



SS SaiGanesh Sakthivel Syncfusion Team June 2, 2023 10:04 AM UTC

Hi Andreas,


As per the current implementation, the class cannot be directly set as the data type for the picker editor in a complex type scenario. This behavior has already been mentioned in the note section.


Note: https://help.syncfusion.com/maui/dataform/editors#loading-the-complex-type-property-values-in-picker


Regards,
SaiGanesh Sakthivel



AN Andreas June 2, 2023 10:29 AM UTC

would it be possible to make it work using a customEditor (

IDataFormEditor)

??



SS SaiGanesh Sakthivel Syncfusion Team June 5, 2023 12:00 PM UTC

Andreas,


As per the implementation, the class cannot be directly set as the data type for the custom editor. Since, it cannot be achieved using the Custom Editor.



AN Andreas June 5, 2023 02:53 PM UTC

ok thank you


Loader.
Up arrow icon