最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Callback for scroll event in Kendo UI grid - Stack Overflow

matteradmin6PV0评论

I have 2 tables rendered with kendo grid, these are scrollable. I have code which needs to be executed whenever the scroll happens in any of the table.

I've tried

jQuery("#grid").kendoGrid({
    dataSource : dataSource,
    columns : [{
        field : 'name',
        title : 'Name',
        width : '160px'
    }, {
        field : 'dataTypeId.name',
        title : 'Type',
        width : '70px'
    }],
    height : 270,
    scrollable : true,
    AfterScroll: function() {
        console.log("scrolled");
    },
    rowTemplate : kendo.template(jQuery("#custom-input-grid-rows").html()),
}).data("kendoGrid");

I tried to put some callbacks like onScroll, AfterScroll but they did not work for me.

How do I get a callback when scrolling happens in the kendo grid?

I have 2 tables rendered with kendo grid, these are scrollable. I have code which needs to be executed whenever the scroll happens in any of the table.

I've tried

jQuery("#grid").kendoGrid({
    dataSource : dataSource,
    columns : [{
        field : 'name',
        title : 'Name',
        width : '160px'
    }, {
        field : 'dataTypeId.name',
        title : 'Type',
        width : '70px'
    }],
    height : 270,
    scrollable : true,
    AfterScroll: function() {
        console.log("scrolled");
    },
    rowTemplate : kendo.template(jQuery("#custom-input-grid-rows").html()),
}).data("kendoGrid");

I tried to put some callbacks like onScroll, AfterScroll but they did not work for me.

How do I get a callback when scrolling happens in the kendo grid?

Share Improve this question edited Jul 17, 2014 at 14:29 gitsitgo 6,8093 gold badges35 silver badges45 bronze badges asked Jul 16, 2014 at 6:22 StrikersStrikers 4,7762 gold badges31 silver badges59 bronze badges 1
  • Those events don't exist in kendo grid, so you can't just simply attach it to the grid definition like that. Also, there is a very big difference between "on" and "after" scroll, please clarify which one you want. – gitsitgo Commented Jul 17, 2014 at 14:36
Add a ment  | 

2 Answers 2

Reset to default 3

Hi got the same question today, and fixed it this way:

Attach the jQuery event .scroll() right after your Kendo Grid was initialized like:

$('#GridName .k-grid-content').scroll(function () { 
    alert('I am scrolling ...'); 
});

The above didn't work for me either, but led me along the correct lines. The k-virtual-scrollable-wrap class handles the the scrollable part of the grid (eg when you have frozen columns enabled), so try this code instead:

$('.k-virtual-scrollable-wrap').scroll(function () { 
    console.log("I am scrolling"); 
});
Post a comment

comment list (0)

  1. No comments so far