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

DisplayIndex ignored

4 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gen
Top achievements
Rank 1
Gen asked on 23 Mar 2011, 09:20 PM
Hello,
On my page, I have some tabs, one with a RadTreeListView, one with a RadGridView. Both have 26+ columns. Users can select witch columns they would like to view, and save that selection for later. The ItemsSource of the grid and treelist and the visibility of the columns are set by data binding. I'm also trying to set the DisplayIndex by data binding.. (I am using Silverlight 4 with MVVM)

<telerik:GridViewDataColumn IsVisible="{Binding Source={StaticResource Locator}, Path=myVM.IsVisibleKey}"
DisplayIndex
="{Binding Source={StaticResource Locator}, Path=myVM.IndexKey}" UniqueName="Item.Key"
Header
="Key" IsGroupable="False" IsReadOnly="True"
CellTemplate
="{Binding Source={StaticResource KeyDataTemplate}}"/>

By default, one of the tabs is set as selected. When I load my page, the data is loaded correctly, and the visibility binding on columns is correct, but the DisplayIndex seem to be attributed randomly. It doesn't even follow the order of the xaml. However, when I select the second tab, that [grid or treelist] has its columns in the correct order. The first tab also seems to be ignoring any change in the column ordering, while the second tab will behave normally and reorder as requested. It doesn't matter witch tab is default select, grid or treelist, the first one will always have wrong column order.

Any idea why this is happening and how to fix it?
I tried to create the columns in code-behind instead of having them all predefined, but it was causing way too much lagging in my page, so it's not really an option.
Thank you
Gen

4 Answers, 1 is accepted

Sort by
0
Yordanka
Telerik team
answered on 29 Mar 2011, 05:29 PM
Hi Gen,

We have tested a scenario similar to yours but everything works fine on our end. Please, refer to the attached project and let us know in case it does not fit your needs. 
 

Best wishes,
Yordanka
the Telerik team
0
Gen
Top achievements
Rank 1
answered on 29 Mar 2011, 09:03 PM

Hi Yordanka,
Thank you for your reply.
Your example is indeed working, even when I modify it to reflect more the structure of my project.

One major difference between your project and mine is that yours has only local variables and calls, while mine has a .web and .wcf projects attached.

Could my problem be because I have to wait for server calls? I am loading a lot of information at the same time that I am creating my grid and treeList (for the side navigation panel, the bottom detail tabbed panel, info for the inline edit, plus my items for the grid (100s)). Could the grid be missing data when it's creating itself, which prevents it to refresh?
Thanks
Gen



0
Vlad
Telerik team
answered on 30 Mar 2011, 06:59 AM
Hello,

 Can you send us small runnable example via support ticket where we can reproduce and debug this issue?

Greetings,
Vlad
the Telerik team
0
Gen
Top achievements
Rank 1
answered on 01 Apr 2011, 01:20 PM
Hello,
We solved this issue by caching the indexes.

In the contructor:
//User IsolatedStorage to get default view column order.
App.UserSetting.TryGetValue<int[]>("DefaultColumnOrder", out m_ListIndex);
//if none found use the default order for a first use.
if (m_ListIndex == null)
{
    m_ListIndex = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10, 11, 12, 13, 14,
                      15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
                      30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44};
}

And when we save the index:
//Put the order in an isolated storage
if (App.UserSetting.Contains("DefaultColumnOrder"))
{
    App.UserSetting.Remove("DefaultColumnOrder");
    App.UserSetting.Add("DefaultColumnOrder", m_ListIndex);
}
else
{
    App.UserSetting.Add("DefaultColumnOrder", m_ListIndex);
}

Tags
GridView
Asked by
Gen
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
Gen
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or