Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add click event for row- Datagrid #2388

Closed
Kath118 opened this issue Aug 10, 2018 · 12 comments
Closed

Add click event for row- Datagrid #2388

Kath118 opened this issue Aug 10, 2018 · 12 comments
Assignees
Labels
controls 🎛️ DataGrid 🔠 Issues on DataGrid control feature request 📬 A request for new changes to improve functionality

Comments

@Kath118
Copy link

Kath118 commented Aug 10, 2018

I'm submitting a...

New Feature

Please add a click event for row in datagrid.
The selection changed event does not work when is necessary to open a new page.
Because to select the same row is necessary select another row and then re-select the previous row.

@kbrons
Copy link
Contributor

kbrons commented Aug 10, 2018

Hi @Kath118, can you create a uservoice request for the issue and add it to your comment?

Thanks!

@kbrons kbrons added controls 🎛️ feature request 📬 A request for new changes to improve functionality DataGrid 🔠 Issues on DataGrid control labels Aug 10, 2018
@Kath118
Copy link
Author

Kath118 commented Aug 10, 2018

@robloo
Copy link
Contributor

robloo commented Oct 30, 2018

A RowPressed and ColumnHeaderPressed event would be very useful for the DataGrid. I need both of these and it's requiring some ugly hacks to get this functionality.

RowPressed should allow detection of both Left and Right mouse button for context menus. DoublePressed would be a bonus.

ColumnHeaderPressed should also allow Left and Right press for context menus. Not sure how to prioritize Left press over Sorting event.

@skendrot
Copy link
Contributor

How would this be different from the SelectionChanged event?

@robloo
Copy link
Contributor

robloo commented Nov 1, 2018

There are many standard use cases that SelectionChanged doesn't support. For example: right click of a row in the table to show a context menu. Also double clicking a row to open it up in an editor. SelectionChanged is conceptually different and has different use cases than a Pressed/Click event. I think ListViewBase supports ItemClick for reference.

Right now I have to implement something like what is below. Usable but it should be out-of-the-box functionality of the DataGrid in my opinion.

        private void DataGrid_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            PointerPoint point = e.GetCurrentPoint(sender as UIElement);

            // Determine the pressed row by navigating the VisualTree (a helper method does this)
            DataGridRow pressedRow = UIUtilities.FindParent<DataGridRow>(e.OriginalSource as DependencyObject);

            if (point.Properties.IsRightButtonPressed)
            {
               // Context menu
            }
            else
            {
               // Do something like track double press and then open a row in an editor
            }
            
            return;
        }

There is then a lot of additional code to track double press and get the index of the DataGridRow and correlate it back into the ItemsSource element so it can be selected, etc.

All of this said, ColumnHeaderPressed is even more useful to implement filtering Flyouts and other controls to edit the columns. I still haven't found a good way to do this one.

@robloo
Copy link
Contributor

robloo commented Nov 18, 2018

Duplicate of #2249

@lukeblevins
Copy link
Contributor

Glad to see that some attention is being paid to this. ;)
In the application I'm building, users currently have to manually select the row before right-clicking in order to display the row-appropriate context menu. Otherwise, it just displays the column header context menu. I think it would be more user-friendly to have a RowRightTapped which autoselects the nearest row and fires (all on rightclick).

@windowstoolkitbot
Copy link

This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

2 similar comments
@windowstoolkitbot
Copy link

This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

@windowstoolkitbot
Copy link

This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

@windowstoolkitbot
Copy link

Issue is inactive. It was automatically closed.

@robloo
Copy link
Contributor

robloo commented Feb 10, 2019

@harinikmsft , @nmetulev Why are issues like this being automatically closed? I understand wanting to avoid permanently open items but these types of things must not just be shutdown automatically. Please change the system from auto-closing these and please reopen this issue.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
controls 🎛️ DataGrid 🔠 Issues on DataGrid control feature request 📬 A request for new changes to improve functionality
Projects
None yet
Development

No branches or pull requests

7 participants