Hi there!
I have this view model:
public class RoomViewModel
{
public TblRooms Rooms { get; set; }
public TblOwners Owners { get; set; }
}
The TblRooms contains: ID, RoomName, OwnerID (can be null).
The TblOwners contains: ID, OwnerName.
And here is method to get RoomListViewer
public List<RoomViewModel> Get RoomListViewer ()
{
List<RoomViewModel> rooms = (from room in context. TblRooms
from owner in context.TblOwners.
Where(o=> room.OwnerID == o.ID).DefaultIfEmpty()
select new RoomViewModel
{
Rooms = room,
Owners = owner,
}).ToList();
return rooms;
}
And using ajax binding to grid like this:
.Columns(columns =>
{
columns.Bound(u => u.Rooms.ID).Title("ID").Width(50);
columns.Bound(u => u.Rooms.RoomName).Title("Room Name").Width(150);
columns.Bound(u => u.Owners.Name).Title("Owner Name").Width(150);
}
My problem is when object Owners has null value, I can’t show "Owner Name" column (only show loading icon forever).
Please tell me the way to fix this problem. Thank!
============================================
Vietnamese History | Vietnamese Culture | Vietnam Travel Guides