Hi Folks,
I have been struffling with the following issue...
I want to achive that a row when it is selected is scrolled to the top of the table.
The table is configured with virtual scolling and the datasource is bound to an odata service with server side paging
My code is working fine as long as the first page of data is shown. When I scroll the table, the row scrolls out of the view.
I would be glad if anyone can help me to find the correct way to calculate the correct scroll amount.
---
var selected = t.mainGrid.select();
if (selected.length == 0) return;
var vs = t.mainGrid.wrapper.find('.k-grid-content').data('kendoVirtualScrollable');
var scrollGridContentOffset = t.mainGrid.wrapper.find('.k-grid-content').offset().top;
var selectContentOffset = t.mainGrid.select().offset().top;
var distance = selectContentOffset - scrollGridContentOffset;
var scrollTop = vs.verticalScrollbar.scrollTop();
vs.verticalScrollbar.animate({ scrollTop: distance + scrollTop }, 250);
--- grid config
t.mainGrid = $('#hist_flights').kendoGrid({
selectable: "row",
change: t.mainGridOnChange,
navigatable: true,
dataSource: {
type: "odata",
transport: {
read: {
url: "https://someurl.com/fis/odata/mydata",
dataType: "json"
}
},
schema: {
data: function(data) {
return data.value;
},
total: function(data) {
return data["odata.count"];
},
errors: function(data) {
},
model: {
fields: {
Id: { type: 'number', nullable: false },
Carrier: { type: 'string' },
FlightNo: { type: 'string' },
OperationalSuffix: { type: 'string' },
CallSign: { type: 'string' },
DateOfOriginUTC: { type: 'date', nullable: false },
DateOfOriginLCL: { type: 'date' },
DateOfOperationUTC: { type: 'date' },
DateOfOperationLCL: { type: 'date' },
DepartureIATA: { type: 'string' },
DepartureICAO: { type: 'string' },
DestinationIATA: { type: 'string' },
DestinationICAO: { type: 'string' },
AcReg: { type: 'string' },
FlightDuplicationNo: { type: 'number' },
BriefingSequenceNo: { type: 'number' },
BriefingComplete: { type: 'boolean' },
Withdrawn: { type: 'boolean' },
State: { type: 'string' },
StateChanged: { type: 'date' },
OFPState: { type: 'string' }
}
}
},
pageSize: 200,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
groupable: true,
sortable: {
mode: "multiple",
allowUnsort: true
},
detailTemplate: kendo.template($("#detail_template").html()),
reorderable: true,
resizable: true,
columnMenu: true,
batch: true,
height: contentHeight,
scrollable: {
virtual: true
},
filterable: {
mode: "row,menu"
},
detailInit: t.detailInit,
columns: [...]
}).data('kendoGrid');
I have been struffling with the following issue...
I want to achive that a row when it is selected is scrolled to the top of the table.
The table is configured with virtual scolling and the datasource is bound to an odata service with server side paging
My code is working fine as long as the first page of data is shown. When I scroll the table, the row scrolls out of the view.
I would be glad if anyone can help me to find the correct way to calculate the correct scroll amount.
---
var selected = t.mainGrid.select();
if (selected.length == 0) return;
var vs = t.mainGrid.wrapper.find('.k-grid-content').data('kendoVirtualScrollable');
var scrollGridContentOffset = t.mainGrid.wrapper.find('.k-grid-content').offset().top;
var selectContentOffset = t.mainGrid.select().offset().top;
var distance = selectContentOffset - scrollGridContentOffset;
var scrollTop = vs.verticalScrollbar.scrollTop();
vs.verticalScrollbar.animate({ scrollTop: distance + scrollTop }, 250);
--- grid config
t.mainGrid = $('#hist_flights').kendoGrid({
selectable: "row",
change: t.mainGridOnChange,
navigatable: true,
dataSource: {
type: "odata",
transport: {
read: {
url: "https://someurl.com/fis/odata/mydata",
dataType: "json"
}
},
schema: {
data: function(data) {
return data.value;
},
total: function(data) {
return data["odata.count"];
},
errors: function(data) {
},
model: {
fields: {
Id: { type: 'number', nullable: false },
Carrier: { type: 'string' },
FlightNo: { type: 'string' },
OperationalSuffix: { type: 'string' },
CallSign: { type: 'string' },
DateOfOriginUTC: { type: 'date', nullable: false },
DateOfOriginLCL: { type: 'date' },
DateOfOperationUTC: { type: 'date' },
DateOfOperationLCL: { type: 'date' },
DepartureIATA: { type: 'string' },
DepartureICAO: { type: 'string' },
DestinationIATA: { type: 'string' },
DestinationICAO: { type: 'string' },
AcReg: { type: 'string' },
FlightDuplicationNo: { type: 'number' },
BriefingSequenceNo: { type: 'number' },
BriefingComplete: { type: 'boolean' },
Withdrawn: { type: 'boolean' },
State: { type: 'string' },
StateChanged: { type: 'date' },
OFPState: { type: 'string' }
}
}
},
pageSize: 200,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
groupable: true,
sortable: {
mode: "multiple",
allowUnsort: true
},
detailTemplate: kendo.template($("#detail_template").html()),
reorderable: true,
resizable: true,
columnMenu: true,
batch: true,
height: contentHeight,
scrollable: {
virtual: true
},
filterable: {
mode: "row,menu"
},
detailInit: t.detailInit,
columns: [...]
}).data('kendoGrid');