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

Is it possible to send some event when currently selected row is clicked?

1 Answer 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 27 Aug 2014, 09:58 AM
<telerik:RadGridView  Margin="0" Height="250" Grid.Row="1" Grid.ColumnSpan="1" Grid.Column="0" VerticalAlignment="Stretch" Grid.RowSpan="7"
    x:Name="rgvAviableSamples"
    ItemsSource="{Binding AviableSampleItems, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }"
    SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
    CanUserFreezeColumns="False"
    CanUserReorderColumns="False"
    AutoGenerateColumns="False"
    ShowGroupPanel="False"
    CanUserResizeColumns="True"
    IsReadOnly="False"
    GridLinesVisibility="None"
    RowIndicatorVisibility="Collapsed"
    ScrollMode="Deferred" 
    ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left"
    ShowColumnHeaders="True"
    SelectionMode="Single"
    SelectionUnit="FullRow"
    local:CustomFilterBehavior.TextBox="{Binding ElementName=tbFilterByLot}">
 
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn UniqueName="IsSelected" Header="" IsReadOnly="True" Width="auto" >
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" telerik:StyleManager.Theme="{StaticResource Theme}" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
 
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" telerik:StyleManager.Theme="{StaticResource Theme}" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
 
        <telerik:GridViewDataColumn UniqueName="Lot" Header="Lot" IsReadOnly="True" Width="*" />
        <telerik:GridViewDataColumn UniqueName="ExpirationDate" Header="ExpirationDate" DataFormatString="{}{0:yyyy-MM-dd}" IsReadOnly="True" Width="*" />
        <telerik:GridViewDataColumn UniqueName="UnitPrice" Header="UnitPrice" IsReadOnly="True" Width="*" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

What I would like to do is:

When I click on some row, the checkbox in the first column is checked, when I click on the same row again (while it is selected), checkbox is unchecked. 

I can check and uncheck rows... but only when the row I want to uncheck is not currently selected, if it is - nothing is happening.

Any way around this?

Thanks in advance.

Best regards.

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 28 Aug 2014, 12:12 PM
Hello,

You can subscribe for the MouseLeftButtonUp event  and monitor all the clicks.
For example:

public MainPage()
{
    InitializeComponent();
    this.radGridView.AddHandler(RadGridView.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnMouseLeftButtonUp), true);
}
 
private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
     FrameworkElement clicked = e.OriginalSource as FrameworkElement;
 
     var clickedCell = clicked.ParentOfType<GridViewCell>();
      
     var clickedRow = clicked.ParentOfType<GridViewRow>();
 
     var boundItem = clickedRow.Item;
     ...
}


Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or