Hi,
I get the error "Uncaught ReferenceError: Customer is not defined" when i try and create a new row on the grid. It will display the data correctly.
My grid is defined like this ...
And my models are like this...
I guess this is because CustomerName is stored in a different table, but I can't figure out why. Any help would be great, I am so lost on this one.
Thanks,
Chris
I get the error "Uncaught ReferenceError: Customer is not defined" when i try and create a new row on the grid. It will display the data correctly.
My grid is defined like this ...
@(Html.Kendo().Grid(Model)
.
Name
(
"OrderGrid"
)
.Columns(columns =>
{
columns.Bound(o => o.OrderId).Title(
"Order Id"
);
columns.Bound(o => o.Customer.CustomerName).Title(
"Customer Name"
);
columns.Bound(o => o.AccountManager).Title(
"AccountManager"
);
columns.Command(command => { command.Destroy(); command.Edit(); });
})
.Pageable()
.Editable(editable => editable.Mode(GridEditMode.PopUp)
)
.ToolBar(commands => commands.
Create
().Text(
"New Order"
))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(o => o.OrderId))
.Events(events => events.Error(
"error"
))
.
Create
(
create
=>
create
.
Action
(
"Orders_Create"
,
"Order"
))
.
Read
(
read
=>
read
.
Action
(
"Orders_Read"
,
"Order"
))
.
Update
(
update
=>
update
.
Action
(
"Orders_Update"
,
"Order"
))
.Destroy(destroy => destroy.
Action
(
"Orders_Destroy"
,
"Order"
))
)
)
And my models are like this...
public
class
Order
{
public
int
OrderId { get;
set
; }
public
int
CustomerId { get;
set
; }
public
string AccountManager { get;
set
; }
public
Customer Customer { get;
set
; }
}
public
class Customer
{
public
int
CustomerId { get;
set
; }
[Required]
public
string CustomerName { get;
set
; }
[Required]
public
string Address1 { get;
set
; }
public
string Address2 { get;
set
; }
public
string Address3 { get;
set
; }
public
string City { get;
set
; }
public
string County { get;
set
; }
[Required]
public
string Postcode { get;
set
; }
private ICollection<
Order
> Orders { get;
set
; }
}
I guess this is because CustomerName is stored in a different table, but I can't figure out why. Any help would be great, I am so lost on this one.
Thanks,
Chris