Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Grid Data/column Headers Dynamically created in MVC 3/4.
posted

I am going to test IgniteUI on a new project. My requirements are as follow: The Controller/Action Result is going to send Data (Model) as Jason to the View. I need to set up IgGrid grid in different places in my web application. The IgGird would get populated dynamically in the View by the Data (Model), this includes Header labels.

The reason I need igGrid to work this way is that we have international clients and we want them to see Label headers in their language and be able to customize them.

The developer will create a new View with a igGrid, the developer will assign a string (number) to the ID or Name of the igGrid. When the igGrid loads it will pass the ID/Name to an Action Result. With the passed ID/Name, the Action Result will get the number of columns, Widths, and Column Headers of the igGrid from a Data Base Table. The Action Result will send the igGrid settings (number of columns, width, and column headers) along with Data/Modle to the View/igGrid

One of purpose of this is to let customers change labels from English to their own languages and customize Labels/Headers from inside a data base table.

Any of you guys have experience on how to do this with igGrids?

I will be using VS 2010, MVC 3 (MCC 4 in the future), and Razor for this project.

Parents
  • 23953
    Offline posted

     

    Hi Todd,

    You can achieve this functionality by using the GridModel class in the controller to dynamically construct the grid configuration.

    In the View you need to set a strongly typed model (Note: That's not the only option. You can use ViewData for example.) to be GridModel. Then you initialize grid in the View with this code @Html.Infragistics().Grid(Model).

    In order to get the data as JSON you set the GridModel.DataSourceUrl to point to an Action Method in which you should set the GridModel.DataSource to point to an IQueryable/DataSet/DataTable object and call GridModel.GetData() to return a JsonResult.

    I'm attaching a sample which demonstrates this approach (Note: You need to recreate the reference to Infragistics.Web.Mvc.dll to point to where your version of the dll is located).

     

    Hope this helps,

    Martin Pavlov

    Infragistics, Inc.

    igGrid_GridModel.zip
Reply Children