I want to realize the following
(1) Receive data every three seconds from the server and update the contents of Grid
(Fewer cells are updated at a time)
(2) Display the grid so that it fits in the window, and display a scroll bar if there are many data
(3) Fix the position of the header of the grid and do not scroll
(4) When the contents of Grid are updated by the processing in (1), the scroll position does not change
Of the above contents, only (4) does not work.
When the contents of Grid are updated by the processing of (1), the scroll position returns to the same position each time.
Is there any solution?
-- (The following is part of the source) --
Index.cshtml
-----------------------------
@Html.EJ().DataManager("DataManager").URL("/AAA/DataSource").Adaptor(AdaptorType.UrlAdaptor)
...
@(Html.EJ().Grid<IEnumerable<XXX>>("Grid")
.DataManagerID("DataManager")
.ScrollSettings(scroll => scroll.Height("100%"))
...
@section Scripts
{
<script>
$(function () {
setInterval(
function () {
var grid = $("#Grid").ejGrid("instance");
grid.refreshContent();
}
, 3000
)
});
</script>
}
...
AAAController.cs
-----------------------------
public ActionResult DataSource(DataManager dataManager)
{
var data = (IEnumerable<XXX>)this.GetData();
return Json(new { result = data });
}
| @Html.EJ().DataManager("DataManager").URL("/Grid/UrlDataSource").Adaptor(AdaptorType.UrlAdaptor) @(Html.EJ().Grid<OrdersView>("FlatGrid") .DataManagerID("DataManager") ---- .Columns(col => { --- })) <script> $(function () { setInterval( function () { var grid = $("#FlatGrid").ejGrid("instance"); grid.refreshContent(); grid.getScrollObject().scrollY(0); } , 3000 ) }); </script> |