I am unable to get the grid to show the date properly when using objects within objects.
Here's a small example of where I am seeing this problem
Here's a small example of where I am seeing this problem
HomeController.cs
public
ActionResult Index()
{
return
View();
}
public
static
IEnumerable<Models.Customer> GetCustomers()
{
var db =
new
Data.SomeDataContext();
var query = ...
return
query;
}
public
static
IEnumerable<Models.Orders> GetOrders()
{
var db =
new
Data.SomeDataContext();
var query = ...
return
query;
}
public
ActionResult CustomerOrder_Read([DataSourceRequest] DataSourceRequest request)
{
var query = from o
in
GetOrders()
join c
in
GetCustomers() on o.CustomerAccountNumber equals c.AccountNumber
select
new
CustomerOrder
{
Order = o,
Customer = c
};
return
Json(query.ToDataSourceResult(request));
}
~/Home/Index.chtml
<
div
>
@(Html.Kendo().Grid<
Apex.Models.CustomerOrder
>()
.Name("Grid")
.Columns(col =>
{
col.Bound(p => p.Order.OrderId);
col.Bound(p => p.Order.Date);
col.Bound(p => p.Order.Status);
col.Bound(p => p.Customer.Name);
col.Bound(p => p.Customer.Mobile);
})
.DataSource(data => data
.Ajax()
.PageSize(10)
.Read(read => read.Action("ServiceOrder_Read", "Home"))
)
.Sortable()
.Pageable()
)
</
div
>
ExampleModels.cs
public
class
CustomerOrder
{
public
Customer Customer {
get
;
set
; }
public
Order Order {
get
;
set
; }
}
public
class
Customer
{
public
string
AccountNumber {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
string
Mobile {
get
;
set
; }
public
DateTime CreatedDate {
get
;
set
; }
public
DateTime ModifiedDate {
get
;
set
; }
}
public
class
Order
{
public
string
Status {
get
;
set
; }
public
string
OrderId {
get
;
set
; }
public
DateTime Date {
get
;
set
; }
}
Result
The problem is that the grid results should show a DateTime; However, it shows this...Order Date Status Name Mobile
00-01 /Date(1364670000000)/ Open Adam 111-111-1111
00-02 /Date(1364670000000)/ Closed Eve 222-222-2222
00-03 /Date(1364670000000)/ Open Buddha 333-333-3333