fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Iterate controls of Pivot Tab and lack of documentation

Open dipesh-wadhwa opened this issue 6 years ago • 6 comments

Just came around a point where we are using SPFx with office-fabric-controls and I can see it is painful because of lack of documentation and example.

I need help or documentation regarding one issue. I need to iterate through controls/fields of Pivot Tab on button click. So, I am using componentRef to refer pivottab and then trying to access this.pivotcomponentRef.current.props.children. But props property is in-accessible. If I am going through wrong way, please suggest correct way to get fields of Pivot Tab on button click. image

dipesh-wadhwa avatar Jan 06 '20 14:01 dipesh-wadhwa

Hi @dipesh-wadhwa, to iterate over the children you should not use the componentRef property, but rather the item parameter that is passed as part of onLinkClick. I've created a codepen here with what I think is your desired behavior. Please let me know if this works for you or if you need anything else. Thanks!

khmakoto avatar Jan 06 '20 19:01 khmakoto

@khmakoto Thanks it helped. I believe you are getting pivot tabs on change event. That's not the objective. I want to get all fields from tab 1 (Fields marked in green in the question) on button click instead of tab change event.

Simple Example is shown in below image: On Click of Get Fields, We want to iterate on controls that are listed in tab 1 i.e., Stage 1 in this case. So basically loop should give us Field 1, Field 2, Field 3 ..... Field N. (Items marked in green) image

dipesh-wadhwa avatar Jan 07 '20 07:01 dipesh-wadhwa

Alright, I understand your issue now. There's no baked in way of doing this in our pivot but you can easily do this yourself. I've modified the codepen to reflect how to do this. Let me know if there is anything else I can do to help!

khmakoto avatar Jan 07 '20 18:01 khmakoto

Thanks a lot @khmakoto it helped. One last question which is not related to this thread but it will be very helpful if you can guide. Can we trigger "onGetErrorMessage" onSubmit or button click?

I know onGetErrorMessage gets trigger onFocusIn and onFocusOut. Is it possible to trigger onSubmit or buttonClick? I will close thread once received response.

dipesh-wadhwa avatar Jan 08 '20 09:01 dipesh-wadhwa

Hi @dipesh-wadhwa, you're welcome! For the onGetErrorMessage question, do you mean for the TextField component?

khmakoto avatar Jan 08 '20 19:01 khmakoto

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!

msft-github-bot avatar Jan 14 '20 21:01 msft-github-bot