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

Girdview row selection

10 Answers 153 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kavi
Top achievements
Rank 1
Kavi asked on 11 Jul 2010, 07:10 AM

Hi,

I've two grids in my page and based on the selected row of the first grid i'm populating the second grid.
The problem is that, i've selected a row and the corresponding data is populated in the second grid, now i click on datapager or grouping  or sorting the second grid data remains but the selection  (highlighter) is not seen in the first grid.

Could you please let me what is the issue
Thanks.

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Jul 2010, 07:30 AM
Hi,

 By default the grid will keep the SelectedItem for such operation - you can set however SelectedItem to desired in case of grouping, paging, etc.

Kind regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kavi
Top achievements
Rank 1
answered on 12 Jul 2010, 08:02 AM
Hi Vlad,

Thanks for your response.
I understand the selected value remains even after sorting or grouping, is there any way to retain the highlighted row even after sorting. Currently after sorting the row highlighting (orange colour) vanishes when data moves to another page.

Thanks
0
Vlad
Telerik team
answered on 12 Jul 2010, 08:11 AM
Hello,

You can use the grid Items collection if you want to keep selection by index instead by data - find desired item in Items and set this item as SelectedItem.

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kavi
Top achievements
Rank 1
answered on 13 Jul 2010, 02:59 AM
Do we have any event that would be triggered on paging, sorting, grouping where i could set the selection of the earlier highlighted row as you suggested
0
Milan
Telerik team
answered on 13 Jul 2010, 04:36 AM

Hello Kavi,

RadGridView has a number of events that can aid you. We have several pair of events where the first one in a pair indicates what operation will occur and the second one indicated that an operation has occurred. For example we have Grouping, Groped, Sorting, Sorted, Filtering, and Filtered events. The events related to paging can be found on RadGridView.Items - PageChanging, PAgeChanged.

Hope this helps.



All the best,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alessandro
Top achievements
Rank 1
answered on 10 Aug 2010, 03:13 PM
It's not really true:
In SL3 version of controls Q1 2010 i had:
<grid:RadGridView Grid.Row="1" x:Name="dgResourcesList"   RowIndicatorVisibility="Collapsed" IsReadOnly="True" Background="#FFFFFF" AutoGenerateColumns="False" CanUserFreezeColumns="False" Visibility="Visible" FontFamily="Verdana" FontSize="10" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserInsertRows="False" CanUserResizeColumns="False" SelectionMode="Multiple" ShowGroupPanel="False" IsFilteringAllowed="False" Width="Auto" ScrollMode="RealTime" ScrollViewer.VerticalScrollBarVisibility="Auto" MaxWidth="600">
                <grid:RadGridView.Columns>
                    <grid:GridViewSelectColumn Width="Auto">
                        <grid:GridViewSelectColumn.Header>
                            <TextBlock Text="Sel." Width="Auto"></TextBlock>
                        </grid:GridViewSelectColumn.Header>
                    </grid:GridViewSelectColumn>
                    <grid:GridViewDataColumn DataMemberBinding="{Binding DisplayName}" Width="*" >
                        <grid:GridViewDataColumn.Header>
                            <TextBlock Text="Descrizione"/>
                        </grid:GridViewDataColumn.Header>
                    </grid:GridViewDataColumn>
                </grid:RadGridView.Columns>
            </grid:RadGridView>
private void Filter_TextChanged(object sender, TextChangedEventArgs e)
        {
            FilterDescriptor filter = null;
            if (dgResourcesList.FilterDescriptors.Count == 0)
            
                filter = new FilterDescriptor();
                filter.Member = "DisplayName";
                filter.Operator = FilterOperator.Contains;
                filter.IsCaseSensitive = false;
                dgResourcesList.FilterDescriptors.Add(filter);
            }else{
                filter = dgResourcesList.FilterDescriptors[0] as FilterDescriptor;
            }
            filter.Value = Filter.Text;
        }

And after changing the filter text and returning back, selected items were mantained, now with SL4 controls version Q2 2010 (same code) this doesn't work as before but it lose the selected items every time.
It is wonderfull that you add a lot of functionality every time but, in my honest opinion, it would be better to mantein previous features also.
Best regards
0
Milan
Telerik team
answered on 17 Aug 2010, 08:00 AM
Hello Alessandro,

Previously the selection was indeed preserved but this was not correct: when you filter, the items that are filtered out must be deselected since they are no longer available and cannot be accessed by the grid.

This is indeed a breaking change and we are sorry for the inconvenience. 

Is this change a show stopper? 

Greetings,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kavi
Top achievements
Rank 1
answered on 17 Aug 2010, 09:03 PM
Hello Milan,

Is there any workaround to select the first row in the grid after the filtering has taken place, currently in my application even after filtering the data, the earlier selected row details are still reflected in the second grid.

Silverlight version: 3
It would be helpful if you could provide me a sample solution to fix this issue.
i'm using Visual studio 2008
0
Milan
Telerik team
answered on 18 Aug 2010, 08:57 AM
Hi Kavi,

You can use the Filtered event to reset the selected item after the grid has been filtered:

public MainWindow()
{
    InitializeComponent();
  
    this.clubsGrid.Filtered += new EventHandler<GridViewFilteredEventArgs>(clubsGrid_Filtered);
}
  
void clubsGrid_Filtered(object sender, Telerik.Windows.Controls.GridView.GridViewFilteredEventArgs e)
{
    if (this.clubsGrid.Items.Count > 0)
        this.clubsGrid.SelectedItem = this.clubsGrid.Items[0];
}


Regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kavi
Top achievements
Rank 1
answered on 18 Aug 2010, 09:51 AM
Thanks its working fine.
Tags
GridView
Asked by
Kavi
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Kavi
Top achievements
Rank 1
Milan
Telerik team
Alessandro
Top achievements
Rank 1
Share this question
or