Setting display indexes in Grid Loaded event are not working

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

    Posted 15 Aug 2012 Link to this post

    Setting display index in Grid Loaded event are not working. When i try to change the display Index for one column, changing display index for previous columns. How can i save the user level Grid settings and i need to set those settings when user comes back.

       public static void GridViewLoaded(object sender, RoutedEventArgs eventArgs)
            {
                var appSettings = IsolatedStorageSettings.ApplicationSettings;
                List<ReOrderColumnsDto> results;
                ReOrderColumnsDto poLineItemsColumnOrder = null;
                if (IsolatedStorageSettings.ApplicationSettings.Contains("ReOrderColumns"))
                {
                    results = (List<ReOrderColumnsDto>)appSettings["ReOrderColumns"];
                    if (results.Count() > 0 && ((GridViewDataControl)(sender)).Name.ToString() == "PODetailsLineItemsGridView")
                    {
                        poLineItemsColumnOrder = results.Where(x => x.UserPreferenceTypeId == (int)ReOrderColumnsEnum.PoLineItemsGrid).FirstOrDefault();
                    }
                }

                var columnOrderList = poLineItemsColumnOrder != null ? poLineItemsColumnOrder.Preferences.Split(',') : null;

                var count = ((GridViewDataControl)(sender)).Columns.Count;


                for (var i = 0; i < count; i++)
                {
                    ((GridViewDataControl)(sender)).Columns[i].DisplayIndex = Convert.ToInt32(columnOrderList[i]);
                }
            }



    how can i set the display indexes for the grid columns.
Back to Top