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. Image for the cookie policy date
close icon

SfDataGrid Pageup and PageDown Programatically

Hii,
   Is It Possible To Achieve  The Functionality  Of KeyBoard PageUp anad PageDown Key Press on SfDataGrid Programatically
  I am Working a Project,Where I Want To PageUp And PageDown SfDataGrid Data On Button Click

3 Replies

JN Jayaleshwari N Syncfusion Team January 10, 2019 12:18 PM UTC

Hi Yogendra,  
Thanks for contacting Syncfusion Support.  
We have analyzed the reported query “SfDataGrid Pageup and PageDown Programatically” from our side. You can achieve your requirement by raising the PreviewKeyDownEvent programmatically.  
 
private void OnPageDown(object obj) 
{ 
    var dataGrid = obj as SfDataGrid; 
    if (dataGrid.SelectedIndex > -1) 
    { 
        var key = Key.PageDown; 
        if (dataGrid.SelectionController == null || dataGrid.SelectionController.CurrentCellManager == null || dataGrid.SelectionController.CurrentCellManager.CurrentCell == null) 
            return; 
        var targetElement = dataGrid.SelectionController.CurrentCellManager.CurrentCell.ColumnElement as GridCell; 
        var routedEvent = Keyboard.PreviewKeyDownEvent; 
 
        targetElement.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(targetElement), 0, key) { RoutedEvent = routedEvent }); 
    } 
 
} 
 
private void OnPageUP(object obj) 
{ 
    var dataGrid = obj as SfDataGrid; 
    if (dataGrid.SelectedIndex > -1) 
    { 
        var key = Key.PageUp; 
        if (dataGrid.SelectionController == null || dataGrid.SelectionController.CurrentCellManager == null || dataGrid.SelectionController.CurrentCellManager.CurrentCell == null) 
            return; 
        var targetElement = dataGrid.SelectionController.CurrentCellManager.CurrentCell.ColumnElement as GridCell; 
        var routedEvent = Keyboard.PreviewKeyDownEvent; 
 
        targetElement.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(targetElement), 0, key) { RoutedEvent = routedEvent }); 
    } 
} 
 
We have attached the sample for your reference and you can download the same from the following location. 
 
Please let us know if you would require further assistance. 
 
Regards, 
Jayaleshwari N 



YO yogendra January 10, 2019 02:09 PM UTC

Thanks A Lot.


JN Jayaleshwari N Syncfusion Team January 11, 2019 10:15 AM UTC

Hi Yogendra, 
 
Thanks for the update. Please get in touch if you would require for further assistance. 
 
Regards, 
Jayaleshwari N. 


Loader.
Live Chat Icon For mobile
Up arrow icon