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.
Related
I am new to react and need your help.
I have a dropdown and on selecting a value I am checking if selected value is not meeting a condition I need to prompt a dialog box to user if he wants to continue to go with the selection,if he selects yes then selected value to be saved in database.
On select and on selecting yes are two callback functions. My query is how to set the state for current selected value during OnSelect callback so that I can make it available within OnSelectYes also.
You should look into https://react-select.com/async
Will make it easier to make this select component that you want.
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.
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}
/>
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..
I would like to have it where i can only select one checkbox at a time and when selected show the textfield associated with the selection. At least have it where i can only select one checkbox at a time. I have setup the dialog to run a choose when statement when for the selections but only want to select one at a time.
You can use listeners to react to user actions e.g.: dynamic dialogs, however you probably want to use radios.