Sort not working when i bind a dictionary to the gridview

2 posts, 0 answers
  1. Ramya
    Ramya avatar
    27 posts
    Member since:
    Jan 2011

    Posted 03 Oct 2011 Link to this post

    Hi Support,
                   
                         i am binding a dictionary to radgridview at runtime  using a converter sort shoul happen when i click on header columns.I attached sortdescriptor and column
    descriptor but its not working any help highly appreciable and even i attached a event still result is same
    CodeBehind(xaml.cs)
    ==========

     

     

    public UserControl1()

     

    {

    InitializeComponent();

     

     

    Dictionary<string, string> dict = new Dictionary<string, string>();

     

    dict.Add(

     

    "Name", "Muneer");

     

    dict.Add(

     

    "Age", "23");

     

    dict.Add(

     

    "Address", "Ameerpet");

     

     

     

    Dictionary<string, string> dict1 = new Dictionary<string, string>();

     

    dict1.Add(

     

    "Name", "Nag Srinivas");

     

    dict1.Add(

     

    "Age", "24");

     

    dict1.Add(

     

    "Address", "Yousufguda");

     

    lstDict1.Add(dict);

    lstDict1.Add(dict1);

     

     

    foreach (var dictionary in lstDict1)

     

    {

     

     

    foreach (KeyValuePair<string, string> pair in dictionary)

     

    {

     

     

    GridViewDataColumn dataCol = null;

     

    dataCol = (

     

    GridViewDataColumn)TableTypeChart.Columns[pair.Key];

     

     

     

    if (dataCol == null)

     

    {

    dataCol =

     

    new GridViewDataColumn();

     

    dataCol.Header = pair.Key;

    dataCol.UniqueName = pair.Key;

    dataCol.SortMemberPath = pair.Key;

    dataCol.Width =

     

    new GridViewLength(75, GridViewLengthUnitType.Auto);

     

    dataCol.DataMemberBinding =

     

    new Binding()

     

    {

    Converter =

     

    new DictionaryConverter(pair.Key)

     

    };

     

    TableTypeChart.Columns.Add(dataCol);

     

    }

    }

    }

     

    TableTypeChart.ItemsSource = lstDict1;

    }

     Xaml Page
    =========

     

     

     

    <telerikGrid:RadGridView x:Name="TableTypeChart" d:LayoutOverrides="Width" ShowGroupPanel="False"

     

     

     

    Background="{x:Null}" AlternateRowBackground="#FF1D1D1D" BorderBrush="Black"

     

     

     

    Foreground="#FF000000" VerticalGridLinesBrush="Black" HorizontalGridLinesBrush="Black"

     

     

     

    ColumnReordered="StandardGridView_ColumnReordered" Sorting="TableTypeChart_Sorting"

     

     

     

    AutoGenerateColumns="False" IsFilteringAllowed="True" GroupPanelBackground="{x:Null}"

     

     

     

    CanUserSortColumns="True" GroupPanelForeground="{x:Null}" CanUserFreezeColumns="False" CanUserReorderColumns="True" CanUserResizeColumns="True"

     

     

     

    CanUserDeleteRows="False" CanUserInsertRows="False" CanUserSelect="True" RowIndicatorVisibility="Collapsed" d:IsHidden="True" />

     





    Thanks and regards,
    Munna
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 06 Oct 2011 Link to this post

    Hello,

     It will be better to use dynamic objects instead similar to my blog post:
    http://blogs.telerik.com/vladimirenchev/posts/11-09-28/dynamic-binding-for-your-silverlight-applications.aspx

    All the best,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top