|
<ejs-grid id="Grid" width="450" actionBegin="actionBegin" actionComplete="actionComplete" allowTextWrap="true" allowSorting="true" allowPaging="true" toolbar="@( new List<object>() { "Search"})">
. . .
<e-grid-pageSettings pageCount="2" pageSize="5"></e-grid-pageSettings>
<e-grid-columns>
. . .
</e-grid-columns>
</ejs-grid>
<script>
function actionBegin(args) {
var grid = this; //grid Instance
scrollLeft = grid.getContent().querySelector('.e-content').scrollLeft; //getting initial scrollbar value
}
function actionComplete(args) {
var grid = this; //grid Instance
grid.getContent().querySelector('.e-content').scrollLeft = scrollLeft; //setting the scrollbar value back
}
</script>
|
|
<div>
<ejs-grid id="Grid" dataSource="ViewBag.DataSource" actionBegin="actionBegin" frozenColumns="2" actionComplete="actionComplete" allowPaging="true" allowSorting="true" toolbar="@(new List<string>() {"Add", "Edit", "Delete", "Cancel", "Update"})">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" width="120"></e-grid-column>
<e-grid-column field="EmployeeID" headerText="Employee ID" format="C2" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" minWidth="80" maxWidth="300"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" format="C2" width="120"></e-grid-column>
<e-grid-column field="OrderDate" headerText="Order Date" type="date" format='yMd' width="170"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="200"></e-grid-column>
<e-grid-column field="ShipName" headerText="ShipName" format="C2" width="120"></e-grid-column>
<e-grid-column field="Verified" headerText="Verified" format="C2" width="120"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
var scrollLeft;
function actionBegin(args) {
var grid = this; //grid Instance
if (grid.getContent().querySelector('.e-movablecontent')) {
scrollLeft = grid.getContent().querySelector('.e-movablecontent').scrollLeft; //getting initial scrollbar value if movable content(frozen columns) available
}
else {
scrollLeft = grid.getContent().querySelector('.e-content').scrollLeft; //getting initial scrollbar value without frozen columns
}
}
function actionComplete(args) {
var grid = this; //grid Instance
if (grid.getContent().querySelector('.e-movablecontent')) {
grid.getContent().querySelector('.e-movablecontent').scrollLeft = scrollLeft; //setting the scrollbar value back
}
else {
grid.getContent().querySelector('.e-content').scrollLeft = scrollLeft; //setting the scrollbar value back
}
}
</script > |
I used Grid in ASP.NET Framework 4.8 JavaScript.
Grid has 2 Frozen columns. Scroll horizontally to far right end, columns 3, 4, 5 will not show, this is correct.
Now scroll vertically, columns 3, 4, 5 will be shown. But horizontal scrollbar still at the far right end.
How to fix this auto scroll to left when scroll vertically if has Frozen columns?
Hi Mingwang,
While scrolling vertically the horizonal scrollbar will not be reset which is the default behavior. To understand your requirement, please share some more details, which will be helpful for us to validate further.
Regards,
Pavithra S