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

[Solved] Grid Orientation

2 Answers 147 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.
Oliver
Top achievements
Rank 1
Oliver asked on 24 Mar 2011, 01:03 PM
Hi @ll,

Is there a way to show the mvc grid in horizontaly orientation?
I have a ViewModel like:

public class DtoMonthlyStatistics
    {
        public int Year { get; set; }
          
        public int Month { get; set; }
  
        public int SupplierID { get; set; }
  
        public string SupplierName { get; set; }    
  
        public decimal TotalRevenue { get; set; }
    
        public int TotalOrderCount { get; set; }
          
        public decimal AverageOrderValue { get; set; }
        
        public int TotalPositionCount { get; set; }
  
        public decimal AveragePositionCount { get; set; }
}

i want to show this properties as Rows and the Results as Columns Like:

Month:                1            2            3            4            ...
Year:                2011    2011        2011        2011        ...
SupplierName:  Test1    Test        Test3    Test4        ...
....

Greats.
Oliver

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Mar 2011, 01:37 PM
Hello Oliver,

 Currently this is not supported. You cannot change the orientation of the grid. I am afraid we cannot easily support this without introducing a new component.

Regards,
Atanas Korchev
the Telerik team
0
Moody
Top achievements
Rank 1
answered on 03 May 2011, 04:35 PM

Hi I know this is an older post but there is actually a way around this, you can return the data as a dictionary containing the key (column header) and its value as the below example

for the controller create a loop around the dictionaryu to extract the values to list


statistics = channel.GetUserStatistics(user.Id.ToString());
                       foreach (KeyValuePair<string, string> x in statistics)
                       {
                           HoldStats.Add(new Statistics(x.Key, x.Value));
                       }
the holdstats variable will then contain the key and the value in a list for your view simply turn off the footer and the header and voila! u have the column headings on the left and values on the right.
<%= Html.Telerik().Grid(Model)
        .Name("stats")
        .Columns(columns=>
        {
            columns.Bound(c => c.Key);
            columns.Bound(c => c.Value);
             
        })
  
         .DataBinding(dataBinding => dataBinding.Ajax().Select("UserStatistics", "Home"))
         .HtmlAttributes(new { @class = "attachment-grid" })
                    .ClientEvents(events => events.OnLoad("HideHeader"))
         .Footer(false)
           
          
                               
         
%>
Tags
Grid
Asked by
Oliver
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Moody
Top achievements
Rank 1
Share this question
or