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
45
Not able to change labels of the child table fields
posted

Not able to change labels of the child's table fields

I am using a XamDataGrid for displaying the information of a dataSet. I have two tables and a relation within the DataSet

I am just using this line of code in my UserControl:

<igDP:XamDataGrid Name="xamDataGrid1" DataSource="{Binding Path=ADataSet.Tables[0].DefaultView}">

</igDP:XamDataGrid>

The information of both tables is shown correctly in a hierarchically way. As I am not setting the AutoGenerateFields to false, all the columns are displayed and the name of the column displayed is the name of the column in the dataSet.

As I want to use a more "friendly" name for the columns I am changing the labels in the code-behind dynamically.

So I changed the fieldLayout of the parent table (FieldLayouts[0]) and then I change the fieldLayout of the child table (FieldLayouts[1]) in the code-behind.

The labels of the parent table are changed correctly, I mean, I can see in the table displayed the "friendly" name for the columns of the parent table. But the labels of the child table are unchanged.

When I debug the code I see that the labels of the FieldLayout of the child table is changed correctly in the code behind(FieldLayouts[1]), but dispate of this, I am not able to see the friendly name when the table is displayed. So for the childs I am still seeing the "unfriendly" name.

This behaviour is really strange because I can see when I debug the code, that I m actually changing the labels of both tables, but for some reason, the childs table displayed is not changing.

 

Parents
  • 28407
    Verified Answer
    posted

    HI,

     I am attaching a sample that binds the XamDataGrid to the NorthWind Order and OrderDetails tables.

     I was able to change the child labels.

     Here is my code snippet:
     private void xamDataGrid1_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)  

           {

                if (e.FieldLayout.Key == "Order Details")    

             {    

                 foreach (Field f in e.FieldLayout.Fields)

                    {       

                  f.Label = f.Name.Replace("ID", "Idenity");

                    }             }         }

     

     I am attaching the sample as well.

    WpfApplication333.zip
Reply Children
No Data