This is a migrated thread and some comments may be shown as answers.

[Solved] Grid Not Showing Collection from View Model

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 09 Aug 2011, 05:36 AM
Hello everyone,

I have run into a problem with the MVC Grid and a collection that is part of my View Model.

I have a page (Razor, and a view model) and in my view model I have a list of address view models:
Address view model:

public class AddressVM{
      
    [DisplayName("Address")]
    public string Address1 { get; set; }
 
    [DisplayName("Address cont")]
    public string Address2 { get; set; }
         
    [DisplayName("City")]
    public string City { get; set; }
         
    [DisplayName("State")]
    public string State { get; set; }
    [DisplayName("Zip Code")]
    public string ZipCode { get; set; }
         
    [DisplayName("Address Type")]
    public string AddressType { get; set; }
 
    public Guid ClientId { get; set; }
 
    public int AddressTypeId { get; set; }
  
}

View Model for page:

public class ClientVM
{
  [ReadOnly(true)]
  [ScaffoldColumn(false)]
  public Guid ID { get; set; }
   
  [DisplayName("First Name"), Required]
  public string FirstName { get; set; }
   
  [DisplayName("Last Name"), Required]
  public string LastName { get; set; }
   
  [UIHint("Date"),DisplayName("Date of Birth"), Required]
  public DateTime DateOfBirth { get; set; }
 
  [DisplayName("Tracking Number"), Required(ErrorMessage = "You must provide a client tracking number"), StringLength(15, ErrorMessage = "You must enter no more than 15 characters")]
  public string ClientTrackingNumber { get; set; }
 
  [DisplayName("Insurance ID Number"), StringLength(11, ErrorMessage = "You must enter no less than 10 characters or more than 11", MinimumLength = 10)]
  public string IDNumber { get; set; }
   
  [DisplayName("Phone Number (numbers only)")]
  public string HomePhone { get; set; }
   
  [DisplayName("Cell Phone Number (numbers only)")]
  public string CellPhone { get; set; }
   
  [DisplayName("Care Giver/Guardian")]
  public string CareGiver { get; set; }
   
  [DisplayName("Approved Units"), Required, DataType("Integer")]
  public int? ApprovedUnits { get; set; }
   
  [DisplayName("Available Units"), ReadOnly(true), UIHint("Label")]
  public int? AvailableUnits { get; set; }
 
  [DisplayName("Is this Client active?"), UIHint("TrueFalseDDL")]
  public bool IsActive { get; set; }
 
  [DisplayName("Addresses"), UIHint("AddressWindow")]
  public string AddressList { get; set; }
 
  [DisplayName("Diagnosis"), UIHint("DiagnosisSelectionBox")]
  public int DiagnosisCode { get; set; }
 
  [DisplayName("Selected Diagnoses List"), UIHint("DiagnosisList")]
  public string SelectedDiagnosisList { get; set; }
 
  [HiddenInput(DisplayValue = false)]
  public string DiagnosisListHidden { get; set; }
 
  public List<int> DiagnosisCodes { get; set; }
 
  [DisplayName("Providers"), UIHint("ProviderWindow")]
  public string Providers { get; set; }
 
  [ScaffoldColumn(false)]
  public Guid UserId { get; set; }
 
  [HiddenInput(DisplayValue = false)]
  public string ProvidersListHidden { get; set; }
 
  [UIHint("ProvidersList"), DisplayName("Selected Provider List")]
  public string SelectedProviderList { get; set; }
 
  public IQueryable<ProviderClientVM> ProvidersList { get; set; }
 
  public IQueryable<DiagnosisClientVM> DiagnosisList { get; set; }
 
  [UIHint("AddressGrid")]
  public List<AddressVM> AddressVM { get; set; }
  public List<UsersVM> Users { get; set; }
}

AddressGrid partial:

@model IEnumerable<AddressVM>
 
@(Html.Telerik().Grid(Model)
        .Name("AddressGrid")
        .Columns(c => {
            columns.Bound(e => e.Address1).Width(25);
            columns.Bound(e => e.Address2).Width(25);
            columns.Bound(e => e.City).Width(25);
            columns.Bound(e => e.State).Width(25);
            columns.Bound(e => e.ZipCode).Width(25);
            columns.Bound(e => e.AddressType).Width(25);
        }))

My Question is:  Why doesn't my Grid (in inline edit mode) show the "AddressGrid" partial that I created? I need to add multiple addresses per client.  Any suggestion of how I can do it?

Thank you.

Tim

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Aug 2011, 02:07 PM
Hello Tim,

Unfortunately, I'm not sure what is the exact scenario you are implementing nor the cause for the issue you have described. Therefore, please provide a small sample application which the demonstrates the issue you are facing.

Regards,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or