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

On itemClick method, e.sender._selectedItemIndex returns previous value

2 Answers 197 Views
Drawer
This is a migrated thread and some comments may be shown as answers.
Deniz
Top achievements
Rank 1
Veteran
Deniz asked on 28 Jul 2020, 11:41 AM

I want to reach selected item's index in the drawer widget. When I examine e.sender from console like this,

console.log(e.sender);

I can find updated value of e.sender._selectedItemIndex.

However, when I want to use e.sender._selectedItemIndex variable directly I get previous value of e.sender._selectedItemIndex. For example, If I open drawer for the first time and select an first item, from console I can see that e.sender's _selectedItemIndex variable is equal to 0 but console.log(e.sender._selectedItemIndex) prints undefined. When I select any other item from drawer, now console.log(e.sender._selectedItemIndex) prints 0. How can I reach and use e.sender._selectedItemIndex's updated value in itemClick function?

 

2 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 30 Jul 2020, 10:34 AM

Hi Deniz, 

It is correct that the itemClick event is triggered before the selection of the drawer has been changed. Therefore, it would always return the previously selected item. 

You could access the currently clicked item via the event arguments:

var item = e.item

Is there a specific functionality that you are willing to achieve and the above code snippet would not be applicable there?

 

Kind regards,
Tsvetomir
Progress Telerik

0
Deniz
Top achievements
Rank 1
Veteran
answered on 31 Jul 2020, 09:00 AM

Hi,

This is not exactly what I've been looking for but this will help my way to solution.

Thank you

Tags
Drawer
Asked by
Deniz
Top achievements
Rank 1
Veteran
Answers by
Tsvetomir
Telerik team
Deniz
Top achievements
Rank 1
Veteran
Share this question
or