We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Popup on CurrentCellEditBegin

Thread ID:

Created:

Updated:

Platform:

Replies:

124895 Jul 6,2016 08:59 PM Jul 8,2016 12:10 AM WPF 3
loading
Tags: SfDataGrid
Tim Stephansen
Asked On July 6, 2016 08:59 PM

Does anyone know how to get the coordinates of a GridCell in a SfDataGrid? I want to have a popup appear with a styled TextBox when the user starts to edit the cell. I want the popup to appear above the cell (but probably bigger than the cell by itself). I have searched and I can't figure out a way to get the cell's location on the screen.

Thank you for any help you can provide!

Sivakumar R [Syncfusion]
Replied On July 7, 2016 07:33 AM

Hi Tim, 
 
Your requirement can be achieved by handling below three events. Find the code snippet and sample below, 
 
 
this.SfdataGrid.CurrentCellBeginEdit += SfdataGrid_CurrentCellBeginEdit; 
this.SfdataGrid.CurrentCellEndEdit += SfdataGrid_CurrentCellEndEdit; 
this.SfdataGrid.Loaded += SfdataGrid_Loaded; 
 
/// <summary> 
/// Open the PopUp and places based on cell's position 
/// </summary> 
/// <param name="sender"></param> 
/// <param name="args"></param> 
private void SfdataGrid_CurrentCellBeginEdit(object sender, CurrentCellBeginEditEventArgs args) 
{ 
    var rowline = this.SfdataGrid.GetVisualContainer().ScrollRows.GetVisibleLineAtLineIndex(args.RowColumnIndex.RowIndex); 
    var colline = this.SfdataGrid.GetVisualContainer().ScrollColumns.GetVisibleLineAtLineIndex(args.RowColumnIndex.ColumnIndex); 
 
 
    popUP.PlacementTarget = this.SfdataGrid.GetVisualContainer(); 
    popUP.Placement = PlacementMode.Relative; 
    popUP.HorizontalOffset = colline.ClippedOrigin; 
    popUP.VerticalOffset = rowline.ClippedOrigin; 
    popUP.IsOpen = true; 
} 
 
/// <summary> 
/// Closes the PopUp. 
/// </summary> 
/// <param name="sender"></param> 
/// <param name="args"></param> 
private void SfdataGrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs args) 
{ 
    popUP.IsOpen = false; 
} 
 
private void SfdataGrid_Loaded(object sender, RoutedEventArgs e) 
{ 
    this.SfdataGrid.GetVisualContainer().ScrollOwner.ScrollChanged += ScrollOwner_ScrollChanged; 
} 
 
/// <summary> 
/// Update the PopUp position while scrolling. 
/// </summary> 
/// <param name="sender"></param> 
/// <param name="e"></param> 
private void ScrollOwner_ScrollChanged(object sender, ScrollChangedEventArgs e) 
{ 
    var currentcell = SfdataGrid.SelectionController.CurrentCellManager; 
 
    if (!currentcell.HasCurrentCell) 
    { 
        popUP.IsOpen = false; 
        return; 
    } 
 
    var rowline = this.SfdataGrid.GetVisualContainer().ScrollRows.GetVisibleLineAtLineIndex(currentcell.CurrentRowColumnIndex.RowIndex); 
    var colline = this.SfdataGrid.GetVisualContainer().ScrollColumns.GetVisibleLineAtLineIndex(currentcell.CurrentRowColumnIndex.ColumnIndex); 
 
    if (rowline == null || colline == null) 
    { 
        popUP.IsOpen = false; 
        return; 
    } 
 
    popUP.HorizontalOffset = colline.ClippedOrigin; 
    popUP.VerticalOffset = rowline.ClippedOrigin; 
    popUP.IsOpen = true; 
} 
 
 
 
Thanks, 
Sivakumar 


Tim Stephansen
Replied On July 7, 2016 08:46 AM

Dear Sivakumar,

Thank you for your assistance. It is greatly appreciated.

Best Regards,

Tim

Jai Ganesh S [Syncfusion]
Replied On July 8, 2016 12:10 AM

Hi Tim, 
 
Thank you for the update. 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Jai Ganesh S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;