Developing a "Genric" Grid

4 posts, 0 answers
  1. Chuck
    Chuck avatar
    1 posts
    Member since:
    Aug 2013

    Posted 11 Dec 2014 Link to this post

    I need to develop Grid controls for a database to provide CRUD operations. The only issue is we got around 600 tables thus looking at ideas on how to make the ASP.MVC grid control razor code more generic. My idea is to decorate the properties on a object with attributes, where I am lost is the Razor part.  May be I have to go all JS and skip Razor code generation ? 

    Thoughts ?

    Jay
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 15 Dec 2014 Link to this post

    Hello Jay,

    We are not sure what are the issues which you are facing in ` the Razor part. `. Can you please explain a bit more?

    Regards,
    Nikolay Rusev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Informed Sources
    Informed Sources avatar
    18 posts
    Member since:
    Jan 2009

    Posted 15 Jan 2015 Link to this post

    I'm looking at something similar.

    I think he means where you bind the columns 

    columns.Bound(p => p.ShipName)            .Width(500)

    how could you pass an model in with an object that defines all the columns to show, their widths and if they're editable. That way you could have the code to set up the grid in one place, and just pass different objects to it to have different content.

    also the read and save would need to point to the correct controller
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 19 Jan 2015 Link to this post

    Hello Adam,

    The Grid option in the view is defined in C#. That said you can always build the columns depending on some settings. The following example demonstrates column definition based on some server settings passed to the view in the ViewData.

    .Columns(columns =>
    {
     foreach (GridColumnSettings d in (List<GridColumnSettings>)ViewData["MyField"])
     {
      columns.Bound(d.MemberType, d.Member)
       .Title(d.Title)
       .Width(d.Width)
       .Sortable(d.Sortable);
      }
    })

    Regards,
    Nikolay Rusev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top