Comments (5)
Hi there,
I'm not sure what you mean by the value not being populated? Does the date not change when you select something from the calendar? Are you setting an initial value
or leaving it undefined? If you are setting the value
prop you also need to make sure to provide an onChange
handler to respond to changes. Are you familiar in general with how form inputs work in React, such as the normal <input>
and <select>
tags, the widgets here work similarly.
if you defined your picker exactly like:
<DateTimePicker name="toDate" format='yyyy-MM-dd' time={false} />
then the input[name=toDate]
will have a value which is a formatted date string (once you select one)
from react-widgets.
I guess I'm not familiar enough with React (just started) I was able to get the value via onChange etc; but before, my expectation was that the input field input[name=toDate] value would update as you chose a new date.
This doesn't seem to be the case, the input's value remains empty no matter what date you choose. Is this normal behavior for the input to never update his value attribute?
from react-widgets.
the value should be updated, did you use the code example above exactly? if not can you include the exact bit of code you are using to declare the date picker? I have tried all the possible situations O can think of that match what you are doing and can confirm they work so we may just be misunderstanding each other.
from react-widgets.
@jquense will do. Don't have the snippet with me this weekend so will have to wait till next week. Thanks for your quick response.
from react-widgets.
no problem,
Generally speaking React has two concepts for inputs, controlled and uncontrolled inputs. A controlled input is one where the parent component manages all the value state for the input. In this case you provide both a value
and an onChange
handler.
render() {
function change(e){
this.setState({ value: e.target.value }) //set state value to the input value
}
// the value of the input will ALWAYS be the value of `this.state.value` so we need to change that
// value in the onChange handler
return (<input value={this.state.value} onChange={change.bind(this)}/>)
}
In the case of uncontrolled inputs you let the input manage its own value like you are used to in normal html. Notice that you do not provide a value
prop to the component.
render() {
function change(e){
console.log(e.target.value )
}
// the value of the input be managed by the input component
return (<input type="text" onChange={change.bind(this)}/>)
}
further reading here: http://facebook.github.io/react/docs/forms.html#controlled-components
from react-widgets.
Related Issues (20)
- focusFirstItem does not work anymore HOT 1
- ComboBox autoFocus not working
- DateTimePicker Cutting in Container make over-flow-x
- feature: change caret to X on combobox
- Multiselect defaultValue doesn't refresh when props value changes HOT 1
- Combobox has unexpected behavior when using hideEmptyPopup
- findDOMNode is deprecated in StrictMode - error HOT 7
- Error finding scss files.
- Calendar: Add option to display week numbers
- Add tailwind 3 support
- Add !default to $max-height in popup.scss
- Deprecation warning with `sass 1.62.0` HOT 2
- Custom tagListComponent HOT 1
- Unable to set tabindex on footer of calendar widget
- How to stablish the value on open DropdownList HOT 3
- Achieved
- Tailwind: [WARNING] "zindex" is not a known CSS property [unsupported-css-property] HOT 1
- Multiselect - Sort tags and options alphabetically HOT 1
- DatePicker monthFormat in version 5
- Virtualized MultiSelect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-widgets.