hypeserver / react-date-range

A React component for choosing dates and date ranges.
MIT License
2.6k stars 678 forks source link

How can i get the name of the cell selected DefinedRange #228

Open in-ten-to opened 6 years ago

in-ten-to commented 6 years ago

Hello,

Can i get the name of the cell that i just clicked on?

handleChange(dates){
        this.setState({
            startDate: moment(dates.selection.startDate),
            endDate: moment(dates.selection.endDate)
    }, function () {
            this.refs.overlay.hide();
        }, this);
    }
render() {
        const selectionRange = {
            startDate: moment(this.state.startDate),
            endDate: moment(this.state.endDate),
            key: 'selection',
        };
        const popoverClickRootClose = (
            <Popover id="dateRange" className="popover bottom">
                <DefinedRange
                    ranges={[selectionRange]}
                    onChange={this.handleChange}
                    locale={fr}
                />
            </Popover>
        );

For now, i handle the change , but i don't know on which cell i clicked, i only know the Start and End Date. Is there a way to get the name or the number of the cell selected? (Today, Yesterday, this week, last week , etc..) ?

Thanks in advance :D

vijay40 commented 3 years ago

Hello,

Can i get the name of the cell that i just clicked on?

handleChange(dates){
      this.setState({
          startDate: moment(dates.selection.startDate),
          endDate: moment(dates.selection.endDate)
  }, function () {
          this.refs.overlay.hide();
      }, this);
  }
render() {
      const selectionRange = {
          startDate: moment(this.state.startDate),
          endDate: moment(this.state.endDate),
          key: 'selection',
      };
      const popoverClickRootClose = (
          <Popover id="dateRange" className="popover bottom">
              <DefinedRange
                  ranges={[selectionRange]}
                  onChange={this.handleChange}
                  locale={fr}
              />
          </Popover>
      );

For now, i handle the change , but i don't know on which cell i clicked, i only know the Start and End Date. Is there a way to get the name or the number of the cell selected? (Today, Yesterday, this week, last week , etc..) ?

Thanks in advance :D

Are you able to figure that out ? I am also struggling with the same issue..

atefBB commented 2 years ago

@vijay40 @in-ten-to any updates about this issue !? I'm struggling too ! Thx

atefBB commented 2 years ago

I solve this issue by forking this package and add the feature I want https://github.com/atefBB/react-date-range/commit/840f63eb9a7c54f7c2722836a23b73dc73ada1af