Custom Col width from XML file is not working

1 posts, 0 answers
  1. Parthasarathy
    Parthasarathy avatar
    2 posts
    Member since:
    Jul 2011

    Posted 01 Apr 2013 Link to this post

    Hi,
     We need to set the width of the columns in RadGridview from a xml file. It is working fine in WPF datagrid. And also it is working fine in RadGridview in visual studio design mode but in run time the widths are not taken from the xml file. Find the code below

    --data1.xml
    <?xml version="1.0" encoding="utf-8" ?>  
    <DatagridColumns xmlns="">
        <DatagridColumn Case_ColumnWidth="150" />
        <DatagridColumn Order_ColumnWidth="100" />
        <DatagridColumn IPName_ColumnWidth="150" />
    </DatagridColumns>

    --RAdGridview code (Main window)
    <Window x:Class="TelerikGridviewColumnWidth.MainWindow"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Grid.Resources>
                <XmlDataProvider x:Key="xmlProvider" Source="XML/data1.xml" XPath="/DatagridColumns/DatagridColumn"/>
            </Grid.Resources>
     
            <telerik:RadGridView AutoGenerateColumns="False" >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Case" Width="{Binding Source={StaticResource xmlProvider}, XPath=//@Case_ColumnWidth}" />
                    <telerik:GridViewDataColumn Header="Order" Width="{Binding Source={StaticResource xmlProvider}, XPath=//@Order_ColumnWidth}" />
                    <telerik:GridViewDataColumn Header="IpName" Width="{Binding Source={StaticResource xmlProvider}, XPath=//@IPName_ColumnWidth}"/>
                    </telerik:RadGridView.Columns>
     
            </telerik:RadGridView>
        </Grid>
    </Window>

    Let us know how to configure the column widths from xml file

    Thanks,
    Parthasarathy  K.
Back to Top