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

Refresh (Reload)

12 Answers 1693 Views
Timeline
This is a migrated thread and some comments may be shown as answers.
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Robert Madrian asked on 18 Sep 2019, 02:51 PM

Hello,

How to reload a timeline (with Kendo grid I can use grid.dataSource.read();)

robert

12 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 23 Sep 2019, 02:39 PM

Hello Robert,

You could rebind the DataSource of an existing Timeline using the setDataSource method:

      var timeline = $("#timeline").data().kendoTimeline;

      $("#btnSubmit").click(function(){
        timeline.setDataSource(new kendo.data.DataSource({
          data: [ {"id":1,"title":"First event","date": new Date(2025, 6, 30)}, 
                      {"id":2,"title":"Second event","date": new Date(2026, 6, 30) }]
        }));
      }); 

The Timeline component is a new one from the latest R3 2019 Kendo UI release. If you like, we can convert this thread to a Feature Request so people can vote for its implementation. Once the request gains popularity, we will apply the necessary changes.

Hope the above helps and please contact us back if you need further assistance.

Regards,
Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 23 Sep 2019, 02:48 PM

My Timeline is bound to a controller method:

@(Html.Kendo().Timeline<MitgliedgeschichteViewModel>()
            .Name("tmlMitgliedgeschichte")
            .DataDateField("Meilensteindatum")
            .DataDescriptionField("Beschreibung")
            .EventHeight(120)
            .DateFormat("dd MMMM yyyy")
            .DataTitleField("Meilenstein")
            .Orientation(TimelineOrientation.Horizontal)
            .DataSource(
                dt => dt.Read("ReadTimeline", "Mitgliedgeschichte", new { mitgliedid = ViewContext.RouteData.Values["mitgliedid"] })
            )
)
0
Nikolay
Telerik team
answered on 26 Sep 2019, 01:27 PM

Hi Robert,

To reload the dataSource of the Timeline you could use the read method the same way as it applies for the Grid:

 $("#Timeline").data("kendoTimeline").dataSource.read();

If there is anything else, we could help with, please contact us back.

Regards,
Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 27 Sep 2019, 11:41 AM

doesn't work here - nothing happens if I use dataSource.read()...

robert

0
Nikolay
Telerik team
answered on 02 Oct 2019, 11:36 AM

Hi Robert,

Thank you for the feedback.

I would recommend you using the setDataSource method. Please refer to my previous reply for further information.

In case you still would like to use the read method of the dataSource you can call the _renderContentHorizontal method to have the Timeline rendered once the data is read.

var timeline = $('#timeline').data('kendoTimeline')
var data = timeline.dataSource.data().slice(2)
timeline.dataSource.read().then(function(){
    timeline._renderContentVertical(timeline.dataSource.data()) // for horizontal mode use _renderContentHorizontal
})

Please try the above and let me know if it works.

Kind regards,
Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 02 Oct 2019, 12:46 PM

doesn't work - after using your code the timeline is without details and seems to be "frezzed"...

if I klick on it I get:

2kendo.all.js:118749 Uncaught TypeError: Cannot read property 'element' of undefined
    at init._setCurrentEvent (kendo.all.js:118749)
    at HTMLLIElement.e (jquery.js?v=hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8:2)
    at HTMLDivElement.dispatch (jquery.js?v=hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8:3)
    at HTMLDivElement.q.handle (jquery.js?v=hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8:3)

 

 

0
Nikolay
Telerik team
answered on 07 Oct 2019, 11:47 AM

Hello Robert,

Thank you for the provided information.

I tested the implementation and from my end, it works as expected. Both options rebind the Timeline with the new data:

Using _renderContentVertical():

var timeline = $('#Timeline').data('kendoTimeline')
var data = timeline.dataSource.data()
var newData = data.slice(4)
timeline._renderContentVertical(newData)

and using setDataSource():

var timeline = $('#Timeline').data('kendoTimeline')
var data = timeline.dataSource.data()
var newData = data.slice(4)
timeline.setDataSource(newData)

For your convenience, I am attaching a small Kendo UI for ASP.NET Core project demonstrating the above. In case I misunderstood the issue you are experiencing, please get back to me with additional explanations. Feel free to change the attached project if needed. I will be happy to assist you.

Regards,
Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 08 Oct 2019, 10:00 AM

doesn't work with your sample - see video here: https://www.screencast.com/t/gXCvgcg4JgX

 

0
Nikolay
Telerik team
answered on 11 Oct 2019, 08:10 AM

Hi Robert,

Thank you for the shared video.

When switching to Horizontal orientation two more methods need to be called to enable the Timeline rebinding:

<script>
    function rebindTimeline() {
        var timeline = $('#Timeline').data('kendoTimeline')
        var data = timeline.dataSource.data()
        var newData = data.slice(4);
        timeline._renderContentHorizontal(newData);
        timeline._redrawEvents();
        timeline._initHorizontal();
    }
</script>

Please accept my apologies for the inconvenience this might caused you. The project has been revised and you can find it attached.

Additionally, I have logged a feature request to add a refresh method to the component. A vote from your behalf has been added and you can get traction and receive votes from other people at the below links:

If there is anything else we could help with, please contact us back.

Regards,


Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 11 Oct 2019, 09:06 AM

maybe this is a misunderstanding but this code doesn't rebind (load data from database) the timeline!
also what ist the number 4 in the data.slice(4)?

I want to load new data from the database...

@(Html.Kendo().Timeline<MitgliedgeschichteViewModel>()
                .Name("tmlMitgliedgeschichte")
                .DataDateField("Meilensteindatum")
                .DataDescriptionField("Beschreibung")
                .EventHeight(120)
                .DateFormat("dd MMMM yyyy")
                .DataTitleField("Meilenstein")
                .Orientation(TimelineOrientation.Horizontal)
                .DataSource(
                    dt => dt.Read("ReadTimeline", "Mitgliedgeschichte", new { mitgliedid = ViewContext.RouteData.Values["mitgliedid"] })
                )
    )

robert

0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 16 Oct 2019, 11:39 AM

Hello, Robert,

My name is Alex and I am covering for my colleague Niko in his absence.

I tested the suggested approach and found that some scenarios and resolutions have unexpected behaviours. This is because there are other internal properties which need to be reset or changed. I addition to that, using private methods is not recommended as they are subject to change without notice.

Therefore, I am afraid that the only safe approach we can offer at the moment is to destroy and recreate the widget as new when you want to refresh it:

<script>
    function rebindTimeline() {
        var timeline = $('#Timeline').data('kendoTimeline');
        var options = timeline.options;
        timeline.destroy();
        $('#Timeline').empty();        
        $("#Timeline").kendoTimeline(options);
    }
</script>

We appreciate that this is not convenient bu it is the safest approach you can take to accomplish what you need while we look into refreshing the widget when its data source data is refreshed.

Please accept our apology for the inconvenience that this may have caused.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 16 Oct 2019, 12:58 PM

Thank's that works

 

robert

Tags
Timeline
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Answers by
Nikolay
Telerik team
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Alex Hajigeorgieva
Telerik team
Share this question
or