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

Developing a "Genric" Grid

3 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Chuck asked on 11 Dec 2014, 05:04 PM
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

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 15 Dec 2014, 09:10 AM
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.

 
0
Informed Sources
Top achievements
Rank 1
answered on 15 Jan 2015, 01:06 PM
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
0
Nikolay Rusev
Telerik team
answered on 19 Jan 2015, 08:08 AM

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.

 
Tags
Grid
Asked by
Chuck
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Informed Sources
Top achievements
Rank 1
Share this question
or