How to access click event of option in React dual list box? - reactjs

I am using react-dual-listbox. Here I am able to select the columns and deselect and use the selected values. But, I want to access the selected option in selected items on click of that particular item.
Ex: if 2 options are selected. If i click on second one, It should give me the value and index of the selected option. I saw something to use selectedRef for that purpose, But I am new to React.
Could anyone please help me out.
<DualListBox
canFilter
preserveSelectOrder
options={this.state.availableColumns}
selected={selectedColumns}
onClick={this.selectedRef}
onChange={this.onColumnSelected}
/>

Related

Select One option At a time

I am using react-native element for checkbox there 4 option for payment but unable to set state for check box
kindly click on link to view code
https://drive.google.com/file/d/1K2yhte4vr2U9H78jUHxMyv3MNimcp-sq/view?usp=sharing
Select Why you are using checkbox? If you want to Select One option At a time use Radiobutton plugin
https://www.npmjs.com/package/react-native-simple-radio-button
Add your payment options in arrays and render it, when you select one option it will automatically setState and selected.

How to remove the selected option in select tag?

I want to create a dropdown in such a way that on click of a button new dropdown is created but it should not show the selected option of the previous dropdown. I am able to create the dropdowns on button click but I can't figure out how to not show selected options of previous dropdowns.
Simply create an Array and map all your dropdowns from that. And in onClick function of button simply pop or modify the array element. I hope you got it. Feel feel to ask doubts and for more please update the source code.

Material-Table replace checkboxes with radio buttons

I'm using material-table to show some data, now I want to select one row at the time to pass the row's data to another component, so being able to select multiple rows at the time isn't what I'm looking for and the main suggestion is to go for a radio button. So is there a way to replace the checkbox on the table with radio buttons or make the selection option to only allow one row to be selected at the time?
According to documentation your hands are tied. But, this might work:
Add selectedRow key to the component which uses MaterialTable
Create some method or function e.g. handleSelection and pass it to onSelectionChange prop. Argument to this func is an array which handleSelection returns
When user select some row, set selectedRow to that row object
If user click on "slelect all" checkbox (top left) - show notification that action is not supported. If there is no way to unselect all checkboxes programatically - unmount and than mount MaterialTable (to reset checkboxes)
If one row is already selected, than another one get selected (which makes two selected rows) - repeat step "4"
I know this is a bit complicated, but it's a best I could think of at the moment
n.b. Another thing you can do (to force users to select only one row) is to hide table on multiple selection and show message about what they can do. Message could be closable. When message get closed fresh table could appear (mount aggain).
Update
Just have found another option that might work for you. Take a look at this page at the "Simple Action Example". There you have buttons instead of checkboxes. I am starting to think that:
options={{
selection: true
}}
is not the right option for you.

Select Unselect logic in Salesforce

I have a requirement, where there is a checkbox on UI when I select it the first time it gets selected when I click it again it is deselected.
So in logic, I am adding the selected parameter to a set, and if it is already present I remove it for deselecting the parameter.
But this approach is not working when I have to count how many I have total, it gives incorrect values.
I have to implement select multiple and deselect multiple in a web page. Can anyone help me with this
Do you have a wrapper? Have a select all/deselect all command link, that command link will call an action which will select/deselect all of the records, then just rerender the table..

How i can turn off autocompletion in Extjs combobox?

When I selected some item in combobox and then I'm trying to select another item in same combobox, I can see only one item - those which is selected right now. I believe that happens because of autocompletion. Does anybody know how I can disable it or something. I need to see all values on each click, regardless if something was selected already or not.
Add triggerAction:'all' to your config.
better add disableKeyFilter:'true' to your combo box

Resources