fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

[Question] Retrieve more info in the onSelectDate

Open OverkillTV opened this issue 8 years ago • 5 comments

Hi All,

I have a DatePicker control that is inside a dynamic table where users can freely add/remove a row.

I want to keep track of the value of the DatePicker control on each row but I couldn't find any ways to put extra attribute on the DatePicker like inputProps: { "data-row-id" : row.ID }.

Also when the event onSelectDate is hit, it only contains the date value and nothing more, no event or anything. Do we have some work around for this ?

Thanks,

OverkillTV avatar Mar 28 '18 17:03 OverkillTV

@lorejoh12 Can you take a look at this one and advise?

michaelangotti avatar Mar 29 '18 17:03 michaelangotti

What scenario are you trying to use this for? I'm not sure what event you're trying to get, the click event from the popup? Not clear to me how useful that would be.

Maybe you're trying to just see which DatePicker's value was changed? For that, my suggestion would be something like this:

<DatePicker
   onSelectDate={this.onSelectDate(rowId)}
...

function onSelectDate = (rowId: string) => (date: Date) => {
   // now you have access to which row you're in, and which date was selected
}

sort of like this: https://codesandbox.io/s/61wmnomnnn

And then you could keep a separate map of values of rowId to selected value perhaps? Hope this is useful.

lorejoh12 avatar Apr 30 '18 23:04 lorejoh12

Thanks @lorejoh12 . I didn't know you could do that in Typescript. That is mind blowing. Could you tell me what this line of code mean ?

function onSelectDate = (rowId: string) => (date: Date) => {
}

Other than that, you suggestion worked !

OverkillTV avatar May 02 '18 08:05 OverkillTV

This issue has been automatically marked as stale because it has not activity for 60 days. It will be closed if no further activity occurs within 14 days of this comment. Thank you for your contributions to Fabric React! Why am I receiving this notification?

stale[bot] avatar Jul 01 '18 08:07 stale[bot]

This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Fabric React! Why am I receiving this notification?

stale[bot] avatar Jul 15 '18 08:07 stale[bot]