Is there an easy way to disable the spinner when loading more content in the list view on endless scroll mode? I can set the following CSS to hide it altogether but this would affect the initial load and load after filter etc
.k-loading-mask { display: none !important; }
Many thanks,
Dale
1 Answer, 1 is accepted
0
Accepted
Stoyan
Telerik team
answered on 12 Dec 2023, 04:30 PM
Hello Dale,
Achieving this requirement for a specific behavior like subsequent fetches of data from the server is indeed tricky.
You can subscribe to the DataSource's RequestStart Event to most accurately catch the time at which the loader appears and set it visibility to hidden.
var requestStart = 0;
function onRequestStart(e){
requestStart++;
if(requestStart==1){
setTimeout(function(){
$(".k-loading-mask").css("visibility","visible");
})
}else{
setTimeout(function(){
$(".k-loading-mask").css("visibility","hidden");
})
}
}
.k-loading-mask{
visibility:hidden;
}
I have applied the code above to this Telerik REPL example. Please give it a try and let me know how it works on your side.
Regards,
Stoyan
Progress Telerik
Stay tuned by visiting our public roadmap and feedback portalpages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
I am having trouble getting this working with my code. It uses an odd mix of taghelper and html helper, I get a console error that the function is not defined? (note I added the on-request-start tag)
Edit: nevermind, it was simply because the script was after instead of before the html
Is there any way to disable the spinner when loading no records in the list view on endless scroll mode? I have tried the above script and CSS to hide it altogether but if block only triggers not else block, how to end the event when no records found on my case?
Many thanks,
Guna
Ivaylo
Telerik team
commented on 26 Feb 2025, 10:00 AM
Hello, Dale
Thank you for the details provided.
To determine whether the collection is empty and hide the spinner accordingly, register for the DataBindingevent of the ListView. The event handler provides an items object that includes a length property. If this property is 0, the collection is empty, and the spinner should be hidden. Below is an example of the implementation: