Do not jump to top of page after editing grid

Hi,

I have a grid on a mobile site with editing mode set to dialog.

When I edit an existing row in the grid and click the save button on the dialog. The page jumps to the top of the top of the page instead of staying focused on the grid and the row that was edited. Is there a way that after edit is complete and the dialog closes, that I can reset focus to the edited row in the grid?


10 Replies

SK Sujith Kumar Rajkumar Syncfusion Team February 21, 2022 05:33 AM UTC

Hi Eddie, 
 
Greetings from Syncfusion support. 
 
We were unable to reproduce the reported problem from our end as the page did not jump to the top with dialog editing in mobile device. You can check the below sample and video demo for reference, 
 
 
 
So please share us the following information to validate further on this, 
 
  • Let us know if the problem is replicated from your end in the above shared sample. If so, let us know the replication steps for the same and if not share us a video demonstration of the problem that you are facing.
  • Let us know the device and browser where the problem is getting reproduced in your case.
  • Have you applied any external custom CSS styles to the Grid control or loaded any external style file that could be affecting the Grid styles? If so please share it.
  • Let us know how you have referenced the script and theme files for the EJ2 Grid control.
  • If possible share us a simple sample to replicate the problem or try reproducing it in the above shared sample.
 
Regards, 
Sujith R 



EW Eddie Willcox replied to Sujith Kumar Rajkumar February 21, 2022 01:01 PM UTC

Hi,


Unfortunately, i cannot provide a sample of the project as it exceeds the 30MB limit for uploads. Basically, it is a normal ASP.NET MVC page. The grid has the EnableAdaptiveUI method set to true. Then I have some javascript to render the grid vertically and set the edit mode to dialog if the browser is a mobile device. Below is my grid page and a little script section to render the grid as above. Also below are some screenshots of the issue:

Code:

<div id = "ControlRegion" class="e-mobile-content">

@Html.EJS().Grid("dataGrid1").DataSource((IEnumerable<object>)ViewBag.dataSource).AllowSorting().AllowFiltering().AllowGrouping().AllowResizing(true).Columns(col =>

   {

       col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).MinWidth("120").Width("200").MaxWidth("300").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();

       col.Field("CustomerID").HeaderText("Customer Name").Width("150").MinWidth("8").Add();

       col.Field("OrderDate").HeaderText("Order Date").Width("200").EditType("datepickeredit").MinWidth("8").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();

       col.Field("Freight").HeaderText("Freight").Width("150").MinWidth("8").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();

       col.Field("ShipCountry").HeaderText("Ship Country").EditType("dropdownedit").MinWidth("8").Width("300").Add();

       col.Field("ShippedDate").HeaderText("Shipped Date").Width("200").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();

       col.Field("ShipName").HeaderText("Ship Name").EditType("dropdownedit").MinWidth("8").Width("200").Add();

       col.Field("Verified").HeaderText("Verified").EditType("booleanedit").DisplayAsCheckBox(true).Type("boolean").MinWidth("8").Width("200").Add();

   }).SelectionSettings(select => select.Type(Syncfusion.EJ2.Grids.SelectionType.Multiple)).Aggregates(agg =>

{

    agg.Columns(new List<Syncfusion.EJ2.Grids.GridAggregateColumn>() { new Syncfusion.EJ2.Grids.GridAggregateColumn() { Field = "Freight", Type = "Sum", GroupFooterTemplate = "Total units: ${Sum}" }, new Syncfusion.EJ2.Grids.GridAggregateColumn() { Field = "Verified", Type = "Truecount", GroupFooterTemplate = "Verified: ${Truecount}" }, new Syncfusion.EJ2.Grids.GridAggregateColumn() { Field = "Freight", Type = "Max", GroupCaptionTemplate = "Maximum: ${Max}" } }).Add();

}).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true); }).Toolbar(new List<string>() { "Search" }).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu); }).EnableAdaptiveUI(true).Load("load").Render()

</div>



<script type="text/javascript">

    function load() {

        var grid = document.getElementById('dataGrid1').ej2_instances[0];

        if (ej.base.Browser.isDevice) {

            document.querySelector('.e-mobile-content').classList.add('e-bigger');

            grid.rowRenderingMode = "Vertical";

            grid.adaptiveDlgTarget = document.getElementsByClassName('e-mobile-content')[0];

            grid.editSettings.mode = "Dialog";

            grid.columns.map((e) => {

                if (e.textAlign == "Center") {

                    e.textAlign = "Left";

                }

                if (e.headerTextAlign == "Center") {

                    e.headerTextAlign = "Left";

                }

                if (e.textAlign == "Right") {

                    e.textAlign = "Left";

                }

            });

        } else {

            grid.rowRenderingMode = "Horizontal";

            grid.editSettings.mode = "Normal";

            grid.columns.map((e) => {

                if (e.textAlign == "Left") {

                    e.textAlign = "Center";

                }

                if (e.headerTextAlign == "Left") {

                    e.headerTextAlign = "Center";

                }

            });

        }

    }

</script>


Screenshots:



Start Edit on order id 10004:


Save Changes and go back to grid:



As you can see, after changes are saved on teh selected record, the page goes all the way back to the top.



SK Sujith Kumar Rajkumar Syncfusion Team February 22, 2022 12:50 PM UTC

Hi Eddie, 
 
Thanks for sharing the details. We are currently validating the reported problem from our end and we will provide you the further details on or before 24th February 2022. 
 
Until then your patience is appreciated. 
 
Regards, 
Sujith R 



SK Sujith Kumar Rajkumar Syncfusion Team February 24, 2022 11:13 AM UTC

Hi Eddie, 
 
Thanks for your patience. 
 
We validated this problem from our end with adaptive view enabled in Grid but unfortunately could not replicate the problem from our end. Please check the below JS Grid sample for reference, 
 
 
So can you please confirm us the following details to validate further on this, 
 
  • Let us know if you are able to replicate the problem case in the above shared sample from your end. If so, share us the replication steps for the same.
  • Share us a video demonstration of the problem for clear understanding.
  • Let us know how you have referenced the script and theme files for the EJ2 Grid control.
  • Let us know the device and browser where the problem is getting reproduced in your case.
 
Regards, 
Sujith R 



EW Eddie Willcox replied to Sujith Kumar Rajkumar February 24, 2022 05:33 PM UTC

Hi,

I am unable to reproduce the issue in your sample. I have however attached a video of what happens on my end.


Script files are referenced in the _Layout.cshtml file 

@Scripts.Render("~/Scripts/ej2/ej2.min.js")


I am using an Android device with Chrome Mobile to reproduce the issue.


Attachment: MobileJumptoTopDemo_75da2e74.zip


SK Sujith Kumar Rajkumar Syncfusion Team February 25, 2022 11:47 AM UTC

Hi Eddie, 
 
We validated the shared video demo but could not see the reported problem as the scroll position was properly maintained in the same positions when editing the following columns - “Code: 'DA0016VA'” , “Code: 'DA0032VA'”. So can you please confirm if you have shared correct replication video demo and if so, can you please the issue with shared video demo. 
 
We also suspect that you might be facing the problem due to referencing old script file for the EJ2 controls. So we suggest you to refer the below online cdn script link instead of the local file in your application, clear the browser cache and check if the problem is resolved, 
 
 
Regards, 
Sujith R 



EW Eddie Willcox replied to Sujith Kumar Rajkumar February 25, 2022 05:06 PM UTC

Thank you.


I do see what you mean. The grid content does stay in the correct position. It's the page position that changes. It goes right back to the top where the logo and navbar are located.



SK Sujith Kumar Rajkumar Syncfusion Team February 28, 2022 11:15 AM UTC

Hi Eddie, 
 
When explicit height is not set for the Grid(which is required when adaptive view is enabled) you might face this problem of page scroll moving to initial position. This is the default browser behavior for this case. So for this we suggest you to set height for the Grid component(if not set previously) to avoid browser scroll jumps. 
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 



EW Eddie Willcox replied to Sujith Kumar Rajkumar February 28, 2022 04:21 PM UTC

Hi,


The grid does have explicit height set with this 

.Height("400px")



SK Sujith Kumar Rajkumar Syncfusion Team March 1, 2022 12:39 PM UTC

Hi Eddie, 
 
We checked this problem from our end by switching to mobile device in chrome browser but still could not reproduce it from our end. Please check the below video demo for reference, 
 
 
We suspect that this problem might be occurring due to some external styles/ theme files loaded in the application or due to referencing old script and theme files for the Syncfusion controls. So we suggest you to refer the below online cdn links for script and theme instead of the local file in your application, clear the browser cache and check if the problem is resolved,  
  
<link rel='nofollow' href=https://cdn.syncfusion.com/ej2/bootstrap5.css rel="stylesheet"> 
 
<script src=https://cdn.syncfusion.com/ej2/dist/ej2.min.js></script> 
 
And if problem still persists then please share us the following information to validate further on this, 
 
  • Share us the Grid and its parent element related code(including styles if applied any).
  • Have you applied any external custom CSS styles to the Grid control or loaded any external style file that could be affecting the Grid styles? If so please share it.
  • If possible try to replicate the problem case in the previously shared sample which will be helpful to identify your exact problem case and validate further based on that.
 
Regards, 
Sujith R 


Loader.
Up arrow icon