We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

KeyPress event in DropDownTree and selected items

I seem to be having 2 issues with the dropdown tree component. 

  • I am having trouble with capturing key press events. 
  • If you dynamically add to the dropdown list that has selected items, the selections are removed. Is this the expected behavior?


Thanks for your time. 

2 Replies

LD LeoLavanya Dhanaraj Syncfusion Team December 16, 2022 12:49 PM UTC

Hi Ken,


Greetings from Syncfusion support.


Issue 1: Trouble with capturing key press events. 


We have validated the mentioned issue in the Angular Dropdown Tee component and are able to reproduce the issue on our end. We have considered the reported issue a bug, and the fix for this issue will be included any of our upcoming releases.


You can track the status of the issue's fix using the following feedback link:


Feedback : https://www.syncfusion.com/feedback/39836/keypress-event-is-not-triggerd-when-allowfiltering-property-is-enabled-in-the


Issue 2: If you dynamically add to the dropdown list that has selected items, the selections are removed


We have validated your reported issue in the Angular Dropdown Tree component. By default, you need to properly refresh the component in order to see the output if you dynamically change any component values. The reported issue also occurs due to the Dropdown Tree component not being properly refreshed while dynamically adding the nodes.


To overcome the reported issue, you need to call the refresh method inside the button's click event. Also, instead of using the value property, you must use the selected property in the field by setting the value to true for the corresponding nodes in the datasource.


Check out the below code snippets and sample.


Sample : https://stackblitz.com/edit/angular-ivy-g24a13?file=src%2Fdrop-down-tree-test%2Fdrop-down-tree-test.component.ts


[drop-down-tree-test.component.html]

<ejs-dropdowntree

    #studentDropdown

    id="studentDropdown"

    <!-- [(value)]="studentListSelected" -->

    [fields]="{

        dataSource: studentList$.value,

        value: 'id',

        text: 'name',

        parentValue: 'pid',

        hasChildren: 'hasChild',

        selected: 'selected'

    }"

    ...

></ejs-dropdowntree>

 

[drop-down-tree-test.component.ts]

//studentListSelected = ['3', '9'];

 

addENGStudents(event: any) {

    this.studentList$.next([

      ...this.studentList$.value,

      ...this.studentList_ENG,

    ]);

    this.studentDropdown.refresh();

}

 

studentList_PHY: any[] = [

    ...

    {

      id: '3',

      lastName: 'Hardin',

      firstName: 'Reid (Make it a long name)',

      middleName: 'Raymond',

      grade: 'Sophomore',

      class: 'PHY',

      major: 'English',

      selected: true,

    }, ...

];

 

studentList_ENG: any[] = [

    ...{

        id: '9',

        lastName: 'Chang',

        firstName: 'Matthew  (Make it a long name)',

        middleName: 'K',

        grade: 'Junior',

        class: 'ENG',

        major: 'English',

        selected: true,

    },

    ...

];


Regards,

Leo Lavanya Dhanaraj



IL Indhumathy Loganathan Syncfusion Team December 30, 2022 10:01 AM UTC

Ken, You are encountering a behavior with the Dropdown Tree component when the allowFiltering option is set to true. In order to move down through the tree nodes using the Down Arrow key, you may need to first use the Tab key to focus on the Tree element. This should allow the keyPress event to trigger properly.


Check out the below sample.

https://stackblitz.com/edit/angular-ivy-g24a13?file=src%2Fdrop-down-tree-test%2Fdrop-down-tree-test.component.ts


Please get back to us if you need any further assistance.


Loader.
Live Chat Icon For mobile
Up arrow icon