I have bound some data to a Kendo grid and the problem I am running into is that the grid seems to only want to show two decimal places instead of 5 or 6 or whatever the real value is for the longitude and latitude columns.
Here is the code in my view:
<div class="gridPadding">
@(Html.Kendo().Grid((IEnumerable<DealerPortal.Models.DealerViewModel>)ViewData["DealerResults"])
.Name("dealerSearchResults")
.Columns(columns =>
{
columns.Bound("DealerID");
columns.Bound("DealerName");
columns.Bound("TerminalID");
columns.Bound("Status");
columns.Bound("Address1");
columns.Bound("State");
columns.Bound("PhoneNumber");
columns.Bound("Email");
columns.Bound("Latitude");
columns.Bound("Longitude");
columns.Bound("EpayRetailerID");
})
.DataSource(dataSource => dataSource.Server().Model(model => model.Id(d => d.DealerID)))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.Sortable()
)
</div>
Here is the DealerViewModel class:
public class DealerViewModel
{
public long DealerID { get; set; }
public string DealerName { get; set; }
public string Address1 { get; set; }
public string PhoneNumber { get; set; }
public string Email { get; set; }
public decimal? Latitude { get; set; }
public decimal? Longitude { get; set; }
public string EpayRetailerID { get; set; }
public string TerminalID { get; set; }
public string State { get; set; }
public char Status { get; set; }
}
When I step through the code I can see that ViewData["DealerResults"] holds the correct values for longitude and latitude, but the grid displayed on the webpage cuts it off after 2 decimal places. I only have the nullable decimal type to satisfy some error I was getting further upstream, but it doesn't seem like that should be the problem.
I also couldn't seem to find the way to format these values as sometimes they are negative values and the amount of decimal places changes.
I tried columns.Bound("Latitude").Format("00.000"); which only made every value "00.000" and columns.Bound("Latitude").Format("##.###"); which also made every value "##.###".
Any ideas? Thank you
Try columns.Bound("Latitude").Format("{0:n6}"); It will fill in all decimal places till the 6th place. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With