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

Keep selection after changing timeview (day/week/month/year)

1 Answer 13 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
David Stacey
Top achievements
Rank 1
David Stacey asked on 24 Mar 2021, 02:31 PM

What's the best way of keeping the selected row in the tree view when the timeview is changed.

i.e. keep the row highlighted when the user clicks on the day/week/month/year tab

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 29 Mar 2021, 08:52 AM

Hello David,

This functionality can be achieved by "persisting" the selected task's data-uid attribute and subscribe once to the dataBound event of the underlying Kendo Gantt widget. 

To achieve that, you can use the OnClientNavigationCommand client-side event with the following event handler declaration:

<script>
    function OnClientNavigationCommand(sender, args) {
        var kendoGantt = sender._widget;
        var selected = kendoGantt.select();
        if (selected[0]) {
            var uid = selected[0].getAttribute("data-uid");
            kendoGantt.one("dataBound", function () {
                kendoGantt.select("[data-uid=" + uid + "]")
            })
        }
    }
</script>

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Raju
Top achievements
Rank 1
commented on 27 Apr 2021, 09:35 AM

Hi Peter,

We have tried the following event

https://docs.telerik.com/devtools/aspnet-ajax/controls/gantt/client-side-programming/events/onclientnavigationcommand

But function OnClientNavigationCommand never get called. 

 

Regards

 

Peter Milchev
Telerik team
commented on 30 Apr 2021, 08:48 AM

Hello Raju, 

Please ensure that you are subscribing property to the event, i.e. the value of the OnClientNavigationCommand property of the Gantt is just the name of the handler function, without any parentheses or brackets: https://docs.telerik.com/devtools/aspnet-ajax/getting-started/customize-control-behavior#client-side-event-handling 

Also, please ensure there are no JavaScript errors in the browser's console: https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/common-general-troubleshooting-javascript-errors 

Tags
Gantt
Asked by
David Stacey
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or