How to update entries' text upon editing underlying model object properties.

I have an sfDataForm control bound to a model object in the viewmodel of the page. Upon clicking a button the data contained in the underlying model object gets sent to the database and the model is destroyed and created anew for the next data entry.

Unfortunately despite the underlying model being bound to the sfDataForm entries they're not updating to reflect the change (destruction and creation anew of the model) and the old data remains in the entries' fields until I manually close and reopen the page. Can the sfDataForm automatically update itself when the bound model's properties are change


3 Replies

SS SaiGanesh Sakthivel Syncfusion Team June 8, 2023 01:11 PM UTC

Hi Nicholas,


As of now, the dataform will automatically update the data object value when we changed the value in the editor view. For the dynamic model change, we suggest you use the property changed event for the data object to update the editor. Please refere to the following code snippet for your reference.


Code Snippet

public MainPage()

{

    InitializeComponent();

    (dataForm.DataObject as ContactInfo).PropertyChanged += MainPage_PropertyChanged;

}

 

private void MainPage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)

{

    if (!string.IsNullOrEmpty(e.PropertyName))

    {

        dataForm.UpdateEditor(e.PropertyName);

    }

}


Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel


Attachment: DataFormMAUI_5f5bfb37.zip


AK Amit Kumar October 11, 2023 06:44 PM UTC

I want to update SfDataForm from web api . 

Problems comes when I want to update combo box field, if it is custom data type. 

even this example doesnt work with combo box field. 

even if I Initialize the property by any other variable or property then also combo box doesn't show data. 

example. 

= new Person{ Name="Ajay", City=AddressList.City, Zip=AddressList.ZipCode, Phone="1312312312"}; 

In above case Name & Phone will show the data but not in city and Zip for Form Combo box. 





VM Vidyalakshmi Mani Syncfusion Team October 12, 2023 01:45 PM UTC

Hi Amit,


Based on the provided information, we have checked your query and were unable to replicate the issue from our end. We tested with scenarios such as initially setting the values for the combo box editors from a variable and loading the values to the combo box editors through the `GetSource` method of the `ItemServiceProvider` class.


We have prepared a simple sample; please refer to the attached sample for your reference.


Additional Information:

SfDataForm version: 23.1.40


Kindly check our sample and confirm if you are still experiencing the same issue. If not, please modify our sample and revert to us with the following details. These details would be helpful for us to analyze further and provide you with a solution as soon as possible:

  • Provide the sample and a video that replicates the issue.



Attachment: DataFormComplexTypes_f6990457.zip

Loader.
Up arrow icon