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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add double click listeners to ListBoxComponent items

Thread ID:

Created:

Updated:

Platform:

Replies:

149671 Dec 5,2019 02:29 AM UTC Dec 5,2019 12:17 PM UTC React - EJ 2 1
loading
Tags: ListBox
Kenneth Tan
Asked On December 5, 2019 02:29 AM UTC

I need to run a function that directly alters my component state that will run whenever the user double clicks an item inside the ListBox, and retrieve that item. Is there any way to do this?  

Madhan Venkateshan [Syncfusion]
Replied On December 5, 2019 12:17 PM UTC

Hi Kenneth, 
 
Thanks for contacting Syncfusion support. 
 
We would like to suggest you to use getDataByValue method to get the item of the ListBox on double clicking the ListBox. We have prepared a sample, please refer the below sample link and code snippets. 
 
 
Index.jsx 
componentDidMount() { 
  setTimeout(()=>{ 
     this.listboxObj.element.parentElement.addEventListener('dblclick', (args)=> { 
     var item = this.listboxObj.getDataByValue(args.target.getAttribute('data-value')); 
     console.log(item); 
    }) 
  }); 
} 
render() { 
        return (<div> 
                <ListBoxComponent dataSource={this.data} ref={(obj)=> {this.listboxObj = obj}}/> 
            </div>); 
    } 
 
 
Regards, 
Madhan V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon