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

Changing Name to RadGridView when Column came from DataSet

3 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Luis Vargas
Top achievements
Rank 1
Luis Vargas asked on 18 Aug 2009, 08:02 PM
Hi... I have a basic question. Sorry, I have little experience with these Telerik Controls and overall with WPF. Basically, I have code like this:

public

 

Window1()

 

{

myAccess =

new DOAccess();

 

mySet =

new DataSet();

 

InitializeComponent();

mySet = myAccess.GetForecastData(mySet, 200802, 0, 0, 0);

mySet.Relations.Add(

"Item", mySet.Tables[0].Columns["forecast_rollup_id"],

 

mySet.Tables[1].Columns[

"forecast_rollup_id"]);

 

mySet.Relations.Add(

"Detail", mySet.Tables[1].Columns["forecast_item_id"],

 

mySet.Tables[2].Columns[

"forecast_item_id"]);

 

 

 

 

this

 

.radGridViewCustomHierarchy.DataMember = mySet.Tables[0].TableName;

 

 

this.radGridViewCustomHierarchy.ItemsSource = mySet;

 

 

}

The thing is that some columns coming from the DataSet were labeled such as "forecast_rollup_id" and I want to change the name of the actual column in the actual grid to something like "Main Item Number" (something more user-friendly). Since I am using a DataSet and I am loading information to the RadDataGrid dynamically, I am not sure how I can change the column name because when I try to get access to the columns property, I get a count value = 0 (So int columns = this.radGridViewCustomHierarchy.Columns.Count; returns zero) therefore I cannot simply do something like this: this.radGridViewCustomHierarchy.Columns["forecast_rollup_id"].HeaderText = "Main Item #"; because I get a xaml error. Furthermore, I may need to rename some columns that contain dynamic values (Thus, I cannot use alies for columns in SQL). A column may be called 200801 which needs to be renamed "Q1 2008" (Quarter One of 2008) in the grid itself. Could you please let me know how I can accomplish this change in naming to columns that were originally populated from a DataSet?

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 19 Aug 2009, 05:31 AM
Hi Luis,

You can use AutoGeneratingColumn event to modify auto-generated columns:

        void RadGridView1_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.UniqueName == "forecast_rollup_id")
            {
                e.Column.Header = "ID";
            }
        }



Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Luis Vargas
Top achievements
Rank 1
answered on 19 Aug 2009, 11:30 PM
Hi Vlad,

Thank you very much for your input. I do not see the AutoGeneratingColumn event in my RadGridView Control, though... I'm currently using version 2009.1.526.35 (Runtime Version v2.0.50727) of Telerik WPF Controls. Is there an alternative event or method for this version that I could use? (Something similar to AutoGeneratingColumn Event for this version?)

I imported Telerik.Windows.Controls, Telerik.Windows.Controls.GridView, Telerik.Windows.Controls.Input, and Telerik.Windows.Control.Input dlls. Please let me know if I'm missing anything.

Thank you,

Luis A. Vargas
0
Vlad
Telerik team
answered on 20 Aug 2009, 05:15 AM
Hi Luis,

This event is available in Q2 2009 - with Q1 I suggest you to try DataLoaded instead.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Luis Vargas
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Luis Vargas
Top achievements
Rank 1
Share this question
or