Jorge Gonzalez
Top achievements
Rank 1
Jorge Gonzalez
asked on 15 Dec 2009, 03:21 PM
Is it possible to display the grid contents in column-row format instead of row-column format without programmatically loading the data in column-row format? What I am looking for is a setting (property) in the grid that I can change that will switch the rows and columns around.
4 Answers, 1 is accepted
0
Hi Jorge,
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The grid does not have such property however you can check this blog post to know more about how to achieve your goal:
http://blogs.telerik.com/stefandobrev/posts/09-02-16/transpose_or_just_rows_as_columns.aspx
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 16 Dec 2009, 02:09 PM
Thanks Vlad!
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 17 Dec 2009, 12:40 AM
Vlad,
The application you pointed me too does work if as Stefans's blog points out you know the shape of your data.
In other words if a specific class exists that describes the data. In the example from Stefan it's the Customer class.
I am loading my data from a file which will vary so I cannot create a class that describes a row of data in the file.
Is there some way to dynamically create a class. The data in the file I load is all string data but the number of fields comprising a row will vary.
Thanks
IList<Customer> customers = Customer.GetAll();
IEnumerable transposed = customers.Transpose();
this.GridView.ItemsSource = customers;
this.GridViewTransposed.ItemsSource = new ProxyEnumerable(transposed);
Stefan's Code
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 18 Dec 2009, 07:08 AM
Hello,
My solution to load the data in column-row format was a brute force approach but it wasn't to bad. My solution loads a 2,127,796 data element file (2614 rows X 814 columns) into the grid in a respectable 6-7 seconds.
Here's a brief description of what I did:
// I use lists because the file I am loading can have a varying number of columns.
List<List<string>> sasData = new List<List<string>>(); // Create a list of lists
List<string> sasDataRow;
DataRow dr;
char[] delimitchars = { '\t' };
string [] readText = File.ReadAllLines(sas_file); //. Loads all the files contents into readText
List<string> ColumnCaptions = (readText[1].Split(delimitchars) ).ToList(); // The second line of the file contains the column captions.
DataTable origGridData = new DataTable("origGridData");
numLoans = readText.Length - 2;
< Create the DataTable columns... >
// Load the sasData list with all the sasDataRow data
for (int i = 0; i < numLoans; i++)
{
sasDataRow = (readText[i + 2].Split(delimitchars)).ToList(); // I skip over the first two entries in readText because they are not // relevant.
if (sasDataRow.Count < ColumnCaptions.Count)
{
return -1;
}
sasData.Add(sasDataRow);
}
// Load the datatable with the sas data.
for (int i = 0; i < ColumnCaptions.Count; i++)
{
dr = origGridData.NewRow();
dr[0] = ColumnCaptions[i]; // The column caption name will appear in the first column
for (int j = 0; j < sasData.Count; j++)
dr[j+1] = sasData[j][i];
this.origGridData.Rows.Add(dr);
}
// Add the datatable to the dataset.
<Dataset name>.Tables.Add(origGridData);
// Load the grid
<Grid name>.ItemsSource = <Dataset name>.Tables[0].DefaultView;