This is a migrated thread and some comments may be shown as answers.

Refresh time

2 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 15 Sep 2017, 04:29 PM
I am using custom AJAX binding on a MVC grid.  I have paging enabled to show the refresh button at the bottom.  Would it be possible to retrieve the refresh time and display somewhere?  Not sure if possible inside of the grid control or somewhere else on the page.  Basically I'd like to display to the user when the grid data was last updated (both on initial load and manually initiating a refresh).  

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 19 Sep 2017, 12:34 PM
Hello Erik,

Possible solution is to append a span that will hold the last updated time in the pager container. Then update the displayed time when the requestEnd event of the data source is fired and it is of type "read". 

Handle requestEnd event:

dataSource.Events(x=> x.RequestEnd("onRequestEnd"))

Event handler logic : 

function onRequestEnd(e) {
    if (e.type === "read") {
        if ($('#lastRefresh').length) {
            $('#lastRefresh')
                .html(kendo.toString(new Date(), "g"))
        } else {
            $('<span id="lastRefresh" class="time">')
                .html(kendo.toString(new Date(), "g"))
                .insertBefore($('.k-pager-info'))
        }
    }
}


The following dojo sample illustrates the aforementioned approach:



Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Erik
Top achievements
Rank 1
answered on 19 Sep 2017, 02:02 PM

Thanks, that was exactly what I was looking for!

Note that my pager was configured to only show the refresh button

.Pageable(pageable => pageable
            .Refresh(true)
            .Info(false)
            .Input(false)
            .Numeric(false)
            .PreviousNext(false))

 

And "k-pager-info" did not exist so I changed the insert before to:

.insertBefore($('.k-pager-refresh')

Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Erik
Top achievements
Rank 1
Share this question
or