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

Setting display indexes in Grid Loaded event are not working

0 Answers 32 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anji
Top achievements
Rank 1
Anji asked on 15 Aug 2012, 09:42 PM
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.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Anji
Top achievements
Rank 1
Share this question
or