I have some trouble using the React Grid of Syncfusion. I want to edit some rows using my own Dialog Template. Calling it with the edit mode = 'Dialog' gives me the default Dialog, which automatically display every data set up in the columns.
Abviously one data row has more than the informations displayed. So I don't know how to set up the GridComponent to use my own Dialog in which I would show every column needed to be edited or added once I save the Grid.
I would be pleased if someone can help me. I guess, my thinking isn't right, bebause nothing seems to changed. I red the documention on the syncfusion officially page and somehow I can't figure it out.
https://help.syncfusion.com/reactjs/grid/editing#dialog-template-form
Here is React Component:
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import { GridComponent, ColumnsDirective, ColumnDirective, Group, Resize, Sort, Search,
ContextMenu, Filter, Page, ExcelExport, PdfExport, Edit, Inject, Toolbar } from '#syncfusion/ej2-react-grids';
import { contextMenuItems, txGridHeader } from '../data/dummy';
import { Header } from '../components';
import { NumericTextBoxComponent } from '#syncfusion/ej2-react-inputs';
import { DatePickerComponent } from '#syncfusion/ej2-react-calendars';
import { DropDownListComponent } from '#syncfusion/ej2-react-dropdowns';
const url = 'https://xxxxxxxxxxxxxxxx/';
const TransactionForm = data => {
return (<div>
<div className="form-row">
<div className="form-group col-md-6">
<div className="e-float-input e-control-wrapper">
<input ref={input=> data.id = input} id="OrderID" name="OrderID" type="text" disabled={!data.isAdd} value={data.OrderID} onChange={this.onChange.bind(this)} />
<span className="e-float-line"></span>
<label className="e-float-text e-label-top"> Order ID</label>
</div>
</div>
<div className="form-group col-md-6">
<div className="e-float-input e-control-wrapper" >
<input ref={input=> this.customerName = input} value={data.CustomerName} id="CustomerName" name="CustomerName" type="text" onChange={this.onChange.bind(this)} />
<span className="e-float-line"></span>
<label className="e-float-text e-label-top">Customer Name</label>
</div>
</div>
</div>
<div className="form-row">
<div className="form-group col-md-6">
<NumericTextBoxComponent id="Freight" format='C2' value={data.Freight} placeholder="Freight" floatLabelType='Always'></NumericTextBoxComponent>
</div>
<div className="form-group col-md-6">
<DatePickerComponent id="OrderDate" value={data.OrderDate} placeholder="Order Date" floatLabelType='Always'></DatePickerComponent>
</div>
</div>
<div className="form-row">
<div className="form-group col-md-6">
<DropDownListComponent id="ShipCountry" value={data.ShipCountry} dataSource={this.shipCountryDistinctData}
fields={{text: 'ShipCountry', value: 'ShipCountry' }} placeholder="Ship Country"
popupHeight='300px' floatLabelType='Always'></DropDownListComponent>
</div>
<div className="form-group col-md-6">
<DropDownListComponent id="ShipCity" value={data.ShipCity} dataSource={this.shipCityDistinctData}
fields={{text: 'ShipCity', value: 'ShipCity' }} placeholder="Ship City"
popupHeight='300px' floatLabelType='Always'></DropDownListComponent>
</div>
</div>
<div className="form-row">
<div className="form-group col-md-12">
<div className="e-float-input e-control-wrapper">
<textarea id="ShipAddress" name="ShipAddress" value={data.ShipAddress} onChange={this.onChange.bind(this)} ></textarea>
<span className="e-float-line"></span>
<label className="e-float-text e-label-top">Ship Address</label>
</div>
</div>
</div>
</div>);
}
const Transactions = () => {
const [transaction, setTransaction] = useState(null);
useEffect(() => {
axios.get(url + 'transaction/')
.then(response => {
setTransaction(response.data)
})
}, []);
return (
<div className='m-2 md:m-10 p-2 md:p-10 bg-white rounded-3xl dark:bg-secondary-dark-bg dark'>
<Header category="Page" title="Transactions" />
<GridComponent id='gridcomp' dataSource={transaction} pageSettings={{ pageSize: 15}}
allowGrouping allowPaging allowSorting
allowExcelExport toolbar={['Add', 'Edit', 'Delete', 'Update', 'Cancel', 'Search']} width='auto'
editSettings={{allowAdding: true, allowEditing: true, allowDeleting: true, mode: 'Dialog'}}
editSettingsTemplate= {{TransactionForm}}>
<ColumnsDirective>
{txGridHeader.map((item, index) => (
<ColumnDirective key={index} {...item} />
))}
</ColumnsDirective>
<Inject services={[ Resize, Search, Sort, Group, ContextMenu,
Filter, Page, Edit, ExcelExport, PdfExport, Toolbar ]} />
</GridComponent>
</div>
)
}
export default Transactions
Try removing the editSettingsTemplate, and add the template inside inside the editSettings.
editSettings={{
allowAdding: true,
allowEditing: true,
allowDeleting: true,
mode: "Dialog",
template: TransactionForm,
}}
Related
I have a bit of trouble here, when I do onClick, I hope I can take 1 item, and the handleUpdate() work great
const [langs,setLangs] = useState([]);
function handleUpdate(item){
console.log(item);
}
{langs.map((item, index) => {
<tr key={index}>
//Some code here
<td className='text-primary'
style={{maxHeight: '21px',width: '8%',maxWidth: '300px'}}
onClick={()=>handleUpdate(item)}>
<ModalEditNgonNgu item={item}/>
</td>
</tr>
}
but I don't know why in 'ModalEditNgonNgu' I rendered all items like this
enter image description here
And When I tried to Edit, it can show only the first item, whatever I click.
This is ModalEditNgonNgu:
import '../../css/style.css';
import { useEffect } from "react";
import { useState, useSelector } from "react";
import { ajaxCallGetUrlDemo, ajaxCallPost } from "../libs/base";
import Select from 'react-select'
import { Const_Libs } from "../libs/Const_Libs";
import languagesList from "./languageList/country";
import { get } from 'jquery';
const ModalEditNgonNgu = (props) => {
const { handleGetLanguage } = props;
const [langName, setLangName] = useState("");
const [mainLangs, setMainLangs] = useState([]);
const [mainLang, setMainLang] = useState("");
const [titleLang, setTitleLang] = useState("");
const [describeLang, setDescribeLang] = useState("");
const [authorLang, setAuthorLang] = useState("");
const [rateLang, setRateLang] = useState("");
const [reviewsLang, setReviewsLang] = useState("");
const [translateList, setTranslateList] = useState([]);
const mainLangOptions = [
{ value: 'vi', label: 'Vietnamese' },
{ value: 'en', label: 'English' },
{ value: 'zh', label: 'Chinese' },
{ value: 'ja', label: 'Japanese' },
{ value: 'de', label: 'German' },
];
console.log(props.item);
const handleMainLang=(e)=>{
const getMainLang = e.target.value;
setMainLang(getMainLang);
}
const handleTransList=(e)=>{
const getTransList = e.target.value;
setTranslateList(getTransList);
}
const handleSubmit = () => {
let arr = [{
nameLanguage: langName,
mainLanguage: mainLang,
titleLanguage: titleLang,
descriptionLanguage: describeLang,
authorLanguage: authorLang,
rateLanguage: rateLang,
reviewsLanguage: reviewsLang,
transLanguage: translateList
}]
console.log(arr);
resetData();
props.editLang(arr,props.item.id);
}
const resetData = () => {
setLangName("");
setMainLang("");
setTitleLang("");
setDescribeLang("");
setAuthorLang("");
setRateLang("");
setReviewsLang("");
setTranslateList([]);
}
return (
<>
<button type="button" className="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModalEditNgonNgu" style={{ fontSize: '14px' }}>
{props.item.language_name}
</button>
<div>
<div className="modal fade" id="myModalEditNgonNgu">
<div className="modal-dialog modal-dialog-centered" style={{ minWidth: '700px' }}>
<div className="modal-content">
<div className="modal-header">
<h4 className="modal-title">Sửa ngôn ngữ</h4>
<button type="button" className="btn-close" data-bs-dismiss="modal" />
</div>
<div className="modal-body">
<form>
<div className="col">
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Tên ngôn ngữ</label>
<input type="text"
className="form-control" id="name-campaign"
placeholder="Nhập tên ngôn ngữ...."
defaultValue={props.item.language_name}
onChange={(e) => setLangName(e.target.value)}
/>
</div>
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Tiêu đề</label>
<input type="text"
className="form-control" id="name-campaign"
placeholder="Nhập tiêu đề...."
defaultValue={props.item.title_lang}
onChange={(e) => setTitleLang(e.target.value)}
/>
</div>
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Mô tả</label>
<input type="text"
className="form-control" id="name-campaign"
placeholder="Nhập mô tả...."
defaultValue={props.item.describe_lang}
onChange={(e) => setDescribeLang(e.target.value)}
/>
</div>
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Tác giả</label>
<input type="text"
className="form-control" id="name-campaign"
placeholder="Nhập tác giả (VD: Author)"
defaultValue={props.item.author_lang}
onChange={(e) => setAuthorLang(e.target.value)}
/>
</div>
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Đánh giá</label>
<input type="text"
className="form-control" id="name-campaign"
placeholder="Nhập đánh giá (VD: Rate)"
defaultValue={props.item.rate_lang}
onChange={(e) => setRateLang(e.target.value)}
/>
</div>
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Lượt đánh giá</label>
<input type="text"
className="form-control" id="name-campaign"
placeholder="Nhập lượt đánh giá (VD: reviews)"
defaultValue={props.item.reviews_lang}
onChange={(e) => setReviewsLang(e.target.value)}
/>
</div>
</div>
<div className="col">
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Ngôn ngữ chính</label>
<Select
onChange={(e) =>setMainLang(e)}
options={mainLangOptions}
/>
</div>
<div className="row-2">
<label htmlFor="name-campaign" className="form-label fs-6 fw-bolder">Những ngôn ngữ dịch</label>
<Select
onChange={(e) =>setTranslateList(e)}
isMulti
isSearchable={true}
options={languagesList}
/>
</div>
</div>
</form>
</div>
<div className="modal-footer">
<button type="button" className="btn btn-success" data-bs-dismiss="modal" onClick={handleSubmit}>Update</button>
<button type="button" className="btn btn-danger" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</>
);
}
export default ModalEditNgonNgu;
Sorry if I wrote ambiguous, but I want to take correct 'item' whenever I click on the button that have language_name. What should I do?
There is not enough information in your question. I will do my best to help you with your issue in the current context.
There are several issues in your code:
Modal Visibility
When you render the list of item, you constantly render the ModalEditNgonNgu for every item. I believe that it is not the desired behavior you want to get. Assuming you want to show the item you clicked on, you can do something like:
function App() {
const [langs,setLangs] = useState([]);
const [selectedItem, setSelectedItem] = useState(undefined);
function handleUpdate(item){
console.log(item);
setSelectedItem(item);
}
return (<>
<table>
{langs.map((item, index) => {
<tr key={index}>
//Some code here
<td className='text-primary' style={{maxHeight: '21px',width: '8%',maxWidth: '300px'}} onClick={()=>handleUpdate(item)}>
This is item {item.id}
</td>
</tr>
}
</table>
{selected Item && <ModalEditNgonNgu item={selectedItem}/>}
</>);
}
In this code, we save the selected item in a state and create a single model based on the selected item.
Please note that this solution is not optimal. Most Modal implementation has some animations when they show up and disappear and should be shown by a property and not by the DOM. I guess you are using Bootstarp, so consider using some React wrapper like React-Boostrap and others.
Key property
When you render bunch of component in a loop, like map, you have to define a unique key prop to the child element, to let React follow and match different renders.
You added <tr key={index}> this is ok, but bad-practice. Key should be unique, index is NOT a good key value. The main goal of the key is let react track your componens. If you remove/insert items in the middle of the list, different items will have same key in different renders.
Since your item has an id property, you better do <tr key={item.id}>.
Arrow functions as props
Doing <td ... onClick={()=>handleUpdate(item)}> will work, but it creates a new function instance on every render, which will re-render every item in the list, every time that the list will be re-render.
It may be OK in your lightweight example, but it may cause performance issues in complex list, so you should avoid that.
i have the login page without the js animation
after i add the animation code i dont get a render in the login page,
i use this to add the annimation
const signUpButton = document.getElementById('signUp')
const signInButton = document.getElementById('signIn');
const container = document.getElementById('container');
signUpButton.addEventListener('click', () => {
container.classList.add("right-panel-active");
});
signInButton.addEventListener('click', () => {
container.classList.remove("right-panel-active");
});
Here's the code:
import React from 'react';
const Loginpart = () => {
return (
<div>
<section className="position-relative pb-0">
<div className="gen-login-page-background" ></div>
<div className="container" id="container">
<div className="form-container sign-up-container">
<form action="#">
<h1 >Create Account</h1>
<span>or use your email for registration</span>
<input type="text" placeholder="Name" />
<input type="email" placeholder="Email" />
<input type="password" placeholder="Password" />
<button>Sign Up</button>
</form>
</div>
<div className="form-container sign-in-container">
<form action="#">
<h1 >Sign in</h1>
<span>or use your account</span>
<input type="email" placeholder="Email" />
<input type="password" placeholder="Password" />
Forgot your password?
<button>Sign In</button>
</form>
</div>
<div className="overlay-container">
<div className="overlay">
<div className="overlay-panel overlay-left">
<h1>Welcome Back!</h1>
<p>To keep connected with us please login with your personal info</p>
<button className="ghost" id="signIn">Sign In</button>
</div>
<div className="overlay-panel overlay-right">
<h1>Hello, Friend!</h1>
<p>Enter your personal details and start journey with us</p>
<button className="ghost" id="signUp">Sign Up</button>
</div>
</div>
</div>
</div>
</section>
</div>
);
};
export default Loginpart;
this is the code for animation :
const signUpButton = document.getElementById('signUp')
const signInButton = document.getElementById('signIn');
const container = document.getElementById('container');
signUpButton.addEventListener('click', () => {
container.classList.add("right-panel-active");
});
signInButton.addEventListener('click', () => {
container.classList.remove("right-panel-active");
});
Chances are, when you start the handler functions, the Loginpart component still hasn't rendered.
Check the constants if they are undefined.
Perhaps this approach is more suitable for you with react
import React, {useState} from 'react'
const Component=()=>{
const [anime, setAnime] = useState(false)
function handleAnimation(){
setAnime(!anime)
}
<div id='container' className={`container ${anime&&'right-panel-active'}`}>
<button onClick={handleAnimation}></button>
</div>
}
export default Component
There are actually several ways to do this, css-in-js, or even with pure javascript, but you would have to ensure that the component is already assembled.
i have created a form which calls the search function after pressing submit button. I want the results of the search to be displayed in another function component (have used React Context for this purpose).
However, i faced an issue where i cannot link it to another route /yourstage/results WITHOUT refreshing the page. If the page is refreshed, my seachResult stored in state will be gone.
import React, { Fragment, useState, useEffect, useContext } from "react";
import { withRouter, Link } from "react-router-dom";
import searchResultContext from "./SearchResultContext";
const Search = () => {
const [wave, setWave] = useState("$perc");
const [pack_hu, setPackHu] = useState("$perc");
const { searchResult, setSearchResult } = useContext(searchResultContext);
useEffect(() => {
console.log(JSON.stringify(searchResult));
}, [searchResult]);
//submit a form to search
const submitSearch = async (e) => {
e.preventDefault()
try {
const response = await fetch(
`http://localhost:5000/yourstage/search/${wave}/${pack_hu}`,
{
method: "GET",
headers: { "Content-Type": "application/json" },
}
);
setSearchResult(await response.json());
//Reset Form and State
document.getElementById("searchForm").reset();
setWave("$perc");
setPackHu("$perc");
} catch (error) {
console.error(error.message);
}
};
//return the form html
return (
<Fragment>
<h1 className="text-center mt-3">Search</h1>
<form id="searchForm" onSubmit={submitSearch}>
<div className="form-group row">
<label htmlFor="Wave" className="col-sm-2 col-form-label">
Wave:
</label>
<div className="col-sm-10">
<input
type="text"
className="form-control"
placeholder="Wave Number"
maxLength="10"
onChange={(e) => setWave(e.target.value)}
/>
</div>
</div>
<div className="form-group row">
<label htmlFor="pack_hu" className="col-sm-2 col-form-label">
Pack HU:
</label>
<div className="col-sm-10">
<input
type="text"
className="form-control"
placeholder="Pack HU"
maxLength="10"
onChange={(e) => setPackHu(e.target.value)}
/>
</div>
</div>
<div className="row text-center mt-5">
{/**Search based on parameter*/}
<div className="col-6">
<button type="submit" className="btn-lg btn-primary">
<Link to="/yourstage/results">Search</Link>
</button>
</div>
</div>
</form>
</Fragment>
);
};
export default withRouter(Search);
I have react form state. After submitting the form I want to send the input values to other component and then showing to browser. I successfully submit the form but when I sent the porps to other component. It does not show anything.
Here is my hero component
import React from "react";
import "./App.css";
import Show from "./Show";
function App() {
const [state, setState] = React.useState({
input: " ",
text: " "
});
const changeHandler = e => {
setState({ ...state, [e.target.id]: e.target.value });
};
const handleSubmit = e => {
e.preventDefault();
console.log(state);
return <Show show={state} />; //this is the component where I am sending props
};
return (
<React.Fragment>
<div className="row">
<form className="col s12" onSubmit={handleSubmit}>
<div className="row">
<div className="input-field col s3">
<input
id="input"
type="text"
data-length="4"
onChange={changeHandler}
/>
<label htmlFor="input_text">Input text</label>
</div>
</div>
<div className="row">
<div className="input-field col s8">
<textarea
id="text"
className="materialize-textarea"
data-length="120"
onChange={changeHandler}
></textarea>
<label htmlFor="textarea2">Right your text</label>
</div>
</div>
<button
className="btn waves-effect blue lighten-1"
type="submit"
name="action"
>
Submit
</button>
</form>
<Show /> //After submit the form I want to show to the browser
</div>
</React.Fragment>
);
}
export default App;
Here is my child component.
import React from "react";
export default function Show({ show }) {
return (
<div>
{show ? (
<ul>
<li>{show.input}</li>
<li>{show.text}</li>
</ul>
) : null}
</div>
);
}
ps: Ignore this message.In order to upload this post I need to. write more 😀.
Calling Method was wrong
handleSubmit is the event activity call .its not component
Inside the handleSubmit component return is not right one
So better pass state value on Show component inside the parent fragment
const handleSubmit = e => {
e.preventDefault();
console.log(state);
};
return (
<React.Fragment>
<div className="row">
<form className="col s12" onSubmit={handleSubmit}>
<div className="row">
<div className="input-field col s3">
<input
id="input"
type="text"
data-length="4"
onChange={changeHandler}
/>
<label htmlFor="input_text">Input text</label>
</div>
</div>
<div className="row">
<div className="input-field col s8">
<textarea
id="text"
className="materialize-textarea"
data-length="120"
onChange={changeHandler}
></textarea>
<label htmlFor="textarea2">Right your text</label>
</div>
</div>
<button
className="btn waves-effect blue lighten-1"
type="submit"
name="action"
>
Submit
</button>
</form>
<Show show={state} /> //pass state directly
</div>
</React.Fragment>
);
Below is the button group component which I used inside the form.How to implement the onchange functions to this button group.I have no Idea how to set the onchange method
import React, {Component} from "react";
import {Popover, OverlayTrigger} from 'react-bootstrap';
import "./ButtonGroup.scss";
const popoverBottom = () =>{
return (
<Popover className="tooltip-popover" title="Here is the where you
give a tooltip">
</Popover>
);
}
export const ButtonGroup = ({
tooltip,
label,
options,
selected,
lableStyle = {},
Title = "Tooltip on top",
}) => {
return (
<div className="nuclei-group">
<p className="nuclei-buttongroup-input"> {label} </p>
<div data-toggle="buttons">
{options.map((option, i) => {
const className = selected == option.value ? "active" : "";
return (
<label
key={i}
style={lableStyle}
className={`btn btn-default nuclei-selection-option ${className}`}
>
<input
type="radio"
name={"name"}
id={option.value}
autoComplete="off"
/>
{option.label}
</label>
);
})}
{tooltip ? (
<span>
<OverlayTrigger trigger="click" rootClose placement="bottom" overlay={popoverBottom()}>
<button type="button" className="btn nuclei-tooltip">?</button>
</OverlayTrigger>
</span>
) : null}
</div>
</div>
);
};
export default ButtonGroup;
then I tried to add on change as below and after submitting the form it doesn't work can somebody help me to resolve it.Normally inside a input tag it works but here? and let me know is this the best way to get values from a form as in the code below
import React, {Component} from "react";
import "./classic-quote.scss";
import {Button, ButtonGroup, InputText} from "../../../components";
import StepBreadcrumb from "../../../components/StepBreadcrumb";
import HeaderTitle from "../../../components/HeaderTitle";
import axios from 'axios';
export default class ClassicQuote extends Component {
constructor(props){
super(props);
this.state = {
insurance_type:'',
vehicle_registration:'',
lease_loan_hire:'',
estimated_market_value:'',
usage:'',
make:'',
model:'',
year:'',
claim_bonus_year:''
}
this.handleSubmit = this.handleSubmit.bind(this);
this.handleChange1 = this.handleChange1.bind(this);
this.handleChange2 = this.handleChange2.bind(this);
this.handleChange3 = this.handleChange3.bind(this);
this.handleChange4 = this.handleChange4.bind(this);
}
handleChange1(e){
this.setState({
make: e.target.value
})
}
handleChange2(e){
this.setState({
model: e.target.value
})
}
handleChange3(e){
this.setState({
year: e.target.value
})
}
handleChange4(e){
this.setState({
insurance_type: e.target.id
})
}
handleSubmit(e){
e.preventDefault();
const quotation = {
make: this.state.make,
model: this.state.model,
year: this.state.year,
insurance_type: this.state.insurance_type
}
console.log('gggggggg'+quotation.make+quotation.model+quotation.year+quotation.insurance_type);
let uri = '/items'
axios.post(uri,quotation).then(response => {
console.log('ela');
}).then(error => {
console.log(error);
});
}
render() {
return <div>
{/* <StepBreadcrumb id="bred" /> */}
<div className="container insureme-form zero-padding">
<form onSubmit={this.handleSubmit}>
<div className="row">
<HeaderTitle mainFirstWord="Insurance" restOfTitle="Detail" headerStyle={{fontWeight: "bold"}} headerIcon={true} />
<div className="nuclei-insurance-detail-step-one">
<div className="col-md-12 col-sm-12 col-xs-12">
<ButtonGroup onChange={this.handleChange4} label="" selected="full" options={[{label: "Full Insurance", value: "full"}, {label: "3rd Party Insurance", value: "3rd"}]} tooltip />
<pre>{JSON.stringify(this.state, '', 2)}</pre>
</div>
<div className="col-md-12 col-sm-12 col-xs-12">
<ButtonGroup label="Do you have a vehicle registration No?" selected="Yes" options={[{label: "Yes", value: "Yes"}, {label: "No", value: "No"}]} tooltip />
</div>
<div className="col-md-12 col-sm-12 col-xs-12">
<ButtonGroup label="Do you have any lease,Loan or hire on vehicle?" selected="Yes" options={[{label: "Yes", value: "Yes"}, {label: "No", value: "No"}]} tooltip />
</div>
<div className="col-md-4 col-sm-4 col-xs-8">
<InputText label={"Estimated Market Value?"} placeholder="Rs." />
</div>
<div className="col-md-12 col-sm-12 col-xs-12">
<ButtonGroup label="Usage?" selected="Private" options={[{label: "Private", value: "Private"}, {label: "Hire", value: "Hire"}, {label: "Rent", value: "Rent"}]} tooltip />
</div>
<div className="col-md-12 col-sm-12 col-xs-12 form-group input-text ">
<label>Make, Model and Year of Manufacture? </label>
<div className="col-md-4 col-sm-4 col-xs-4 zero-padding-left">
<input type="text" className="form-control" id={"make-manufacture"} placeholder={"Make"} onChange={this.handleChange1} />
</div>
<div className="col-md-3 col-sm-3 col-xs-4 zero-padding-left">
<input type="text" className="form-control" id={"model-manufacture"} placeholder={"Model"} onChange={this.handleChange2}/>
</div>
<div className="col-md-2 col-sm-2 col-xs-3 zero-padding-left">
<input type="text" className="form-control" id={"year-manufacture"} placeholder={"Year"} onChange={this.handleChange3}/>
</div>
</div>
<div className="col-md-12 col-sm-12 col-xs-12 form-group input-text">
<label>No Claims Bonus?</label>
<div className="col-md-4 col-sm-4 col-xs-8 zero-padding-left">
<InputText tooltip placeholder="No. of Years" />
</div>
</div>
<div className="col-md-12 col-sm-12 col-xs-12">
<Button type="submit" color="red" className="nuclei-bottom-red-button">
Get a Quick Quote
</Button>
<Button type="clear" color="gray" className="nuclei-bottom-gray-button">
Clear
</Button>
</div>
</div>
</div>
</form>
</div>
</div>;
}
}
I tried several ways can get only the make model and year values as printed in the console log
if you want to pass an handler like this:
onChange={this.handleChange4}
you have to add it to the props you receive in Component:
export const ButtonGroup = ({
onChange,
tooltip,
label,
options,
selected,
lableStyle = {},
Title = "Tooltip on top",
}) => {
...
and then in the input elements call onChange:
<input
onChange={onChange}
type="radio"
name={"name"}
id={option.value}
autoComplete="off"
/>
If you want to see the complete solution, I build it in sandbox: Full example here
I saw that you update the form, but you didn't add "onChange" in the ButtonGroup Component file like in the comment:
export const ButtonGroup = ({
onChange, <---this
tooltip,
label,
options,
selected,
lableStyle = {},
Title = "Tooltip on top",
}) => {
return (
<div className="nuclei-group">
<p className="nuclei-buttongroup-input"> {label} </p>
<div data-toggle="buttons">
{options.map((option, i) => {
const className = selected == option.value ? "active" : "";
return (
<label
key={i}
style={lableStyle}
className={`btn btn-default nuclei-selection-option ${className}`}
>
<input
onChange={onChange} <---this
type="radio"
name={"name"}
id={option.value}
autoComplete="off"
/>
{option.label}
</label>
);
})}