We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Databinding will not work

Thread ID:

Created:

Updated:

Platform:

Replies:

149761 Dec 8,2019 03:52 PM UTC Dec 11,2019 12:46 PM UTC Blazor 3
loading
Tags: ListView
paul stanley
Asked On December 8, 2019 03:52 PM UTC

Hi

I am having problems getting the below code to work. To get it to work all I have to do if un-comment the highlighted text. It looks like a bug?

@page "/test"
@using Syncfusion.EJ2.Blazor.Lists
@using System.Collections.ObjectModel
@using Newtonsoft.Json

<button @onclick="AddNew">ADD NEW OBJECT</button>
<EjsListView DataSource="@addresses"
             ModelType="@addressType"
             CssClass="e-list-template">
    <ListViewTemplates>
        <Template>
            <div class="e-list-wrapper">
                <span class="e-list-content">@((context as PickUpPoint).Address)</span>
            </div>
        </Template>
    </ListViewTemplates>
</EjsListView>
@code{
    void AddNew()
    {
        addresses.Add(new PickUpPoint {Address = "an address" });
    }
    ObservableCollection<PickUpPoint> addresses = new ObservableCollection<PickUpPoint>();
    PickUpPoint addressType = new PickUpPoint();
    public class PickUpPoint
    {
        public string Address { get; set; } = string.Empty;
        public double Lat { get; set; } = 0;
        public double Lon { get; set; } = 0;
        public string Coordinates { get { return $"{Lat.ToString()} {Lon.ToString()}"; }}

    }
}

Muthukrishnan Kandasamy [Syncfusion]
Replied On December 9, 2019 11:08 AM UTC

Hi Paul, 
 
Thanks for contacting Syncfusion support. 
 
You can use the following code block to return the coordinates value in the ListView component. 
 
Refer to the below code block: 
public string Coordinates() 
        { 
            return $"{ Lat.ToString()} {Lon.ToString()}"; 
        } 
 
We have prepared sample with your code for your reference. Kindly refer to the below link for the link. 
 
Sample link:  
 
 
Please let us know if you have any concerns. 
 
 
Regards, 
Muthukrishnan K 


paul stanley
Replied On December 9, 2019 07:26 PM UTC

Ok thank you. Is there any reason why you can not use a calculated property?

Sowmiya Padmanaban [Syncfusion]
Replied On December 11, 2019 12:46 PM UTC

Hi Paul, 
 
It is possible to use the calculated property in Listview component. We have checked your attached code snippet, we have sorted out the issue that Coordinates are not declared properly in your code snippet. 
 
 Refer the below code snippet for declaring the Coordinates in your application. 
public string Coordinates 
        { 
            get 
            { 
                return $"{this.Lat.ToString()} {this.Lon.ToString()}"; 
            } 
            set 
            { 
 
            } 
        } 
 
To your reference, we have prepared a sample using calculated property. Refer the sample link below. 
 
Please let us know, if you have any concerns. 
 
Regards, 
Sowmiya.P 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon