vtfuture / BForms

Bootstrap Forms for ASP.NET MVC
MIT License
62 stars 33 forks source link

Grid Example not works #216

Closed Pepo-BG closed 9 years ago

Pepo-BG commented 9 years ago

Hello,

I tried your tutorials ( http://bforms.veritech.io/Start/Grid#views ) and examples ( http://bforms.veritech.io/Demo/Contributors/?stateId=3 ), but they not work. I received errors

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0311: The type 'EM.Models.MoviesRowModel' cannot be used as type parameter 'TRow' in the generic type or method 'BForms.Html.GridExtensions.BsGridFor<TModel,TRow>(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression<System.Func<TModel,BForms.Models.BsGridModel>>)'. There is no implicit reference conversion from 'EM.Models.MoviesRowModel' to 'BForms.Models.BsItemModel'.

The code, which I type can be found in next link: https://dotnetfiddle.net/pJAmwG Can you explain me where's the problem or send me working example? Thank you!

lvv83 commented 9 years ago

I had the same issue. Its looks like the documentation is outdated. To fix this we need to inherit row model from BsItemModel class.

public class MoviesRowModel: BsItemModel
{
    public int Id { get; set; }

    [BsGridColumn(Width = 4, IsEditable = true, IsSortable = true)]
    public string Title { get; set; }

    [BsGridColumn(Width = 2, IsEditable = false, IsSortable = true)]
    public decimal WeekendRevenue { get; set; }

    [BsGridColumn(Width = 2, IsEditable = false, IsSortable = false)]
    public decimal GrossRevenue { get; set; }

    [BsGridColumn(Width = 2, IsEditable = false, IsSortable = true)]
    public DateTime ReleaseDate { get; set; }

    [BsGridColumn(Width = 2, IsEditable = false, IsSortable = true)]
    public bool Recommended { get; set; }

    // don't forget this
    public override object GetUniqueID()
    {
          return Id;
    }
}