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

[Solved] Create Columns in the Controller

2 Answers 82 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.
Kevin Jensen
Top achievements
Rank 1
Kevin Jensen asked on 07 Apr 2010, 06:44 PM
I have an application that I would love to use MVC Grid for.  It pulls the fields to display from the database in the controller.  I want to be able to create the columns, set proper filtering and sorting on applicable fields in the controller.

Does anyone have a snippet on how this can be established?


2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Apr 2010, 07:25 AM
Hi Kevin Jensen,

This is not currently supported. However you can cast your vote for this feature which sounds like the same thing you are requesting.

Regards,
Atanas Korchev
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.
0
IQworks
Top achievements
Rank 1
answered on 08 Apr 2010, 01:15 PM
Hi, 
    Dont know if this would help in the meantime, Its just an idea.
    Suppose you build a ViewModel with fields (columns)  that looked like this (these would be the ACTUAL field names).... 
    
     string gField1
     string gField2
     string gField3  

     Inside your controller, you could populate these gFields with whatever data you wanted, as long as you format them inside of the controller - which I think is one of things you want. Then, in the grid, just display the ViewModel fields ?

     As for setting your filtering and sorting, I have set some properties up inside the controller and passed them to the partialview inside TempData[property], Session[variable], or maybe even the ViewData[property] like below, maybe the properties you want to see can be done likewise.
    
  tabstrip.Add()  
                 .Text((String)Resources.BCAResources.coxCompany)   
                 .HtmlAttributes(new { style="background-color:blue;color:white;",   
                  @class="tabwork" })                   
                 .LoadContentFrom("CompanyGrid", "Company")  
                 .Visible((bool)Session["CompanyGrid"]);  
 
                TabStripItemBuilder tabld = tabstrip.Add()  
                .HtmlAttributes(new { style = "background-color:blue;color:white;" })  
                .Visible((bool)TempData["CompanyData"]);  
                if (Session["CompanyTab"] == "Create")  
                {  
                    tabld.Text((String)Resources.BCAResources.coxEnterCompany);   
                    tabld.LoadContentFrom("CompanyForm", "Company", new { request = "Create", id = 0 });  
                }  
                else if (Session["CompanyTab"] == "Edit")  
                {  
                    tabld.Text((String)Resources.BCAResources.coxEditCompany);  
                    tabld.LoadContentFrom(Url.Action("CompanyForm", "Company", new { request = "Edit", id = Convert.ToInt32(Session["CompanyIdToEdit"].ToString())}));  
                }    
               
            })  
            .SelectedIndex(Convert.ToInt32(TempData["workIndex"]))   
            .Render();  
        %> 
     
Tags
Grid
Asked by
Kevin Jensen
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
IQworks
Top achievements
Rank 1
Share this question
or