-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select options are not matched #141
Comments
Hey @WoutervanderLoopNL, the automatic matching is only for column headers, there is no logic to match select values. If you would like to add that, PRs are welcome. But I think it should be possible to match data in I guess it's hard to find your column data in the raw data, because we don't expose the index anywhere. |
the I was already in the there you have the on MatchColumnsStep.tsx:70 you convert that flat array to a more deeper array with the matched options: I was testing with this, to convert that flat array to the deeper array in the callback, but then React gives an error i cant pass that parameter anymore. Im not that good/experienced with React/NodeJS to find out whats going wrong. selectHeaderStepHook={async (headerValues, data) => {
console.log(headerValues)
console.log(data)
headerValues = [...headerValues.map((value, index) => ({ type: 0, index, header: value ?? "" }))]
headerValues[6] = Object.assign({}, headerValues[6], {matchedOptions: [{entry: "Kantoor 2", value: 14}], value: "warehouse_zone_id"});
console.log(headerValues)
return {headerValues, data};
}} That said. on the mapping step. you have a list with values (from the excel) that needs to be matched. and you have for every value a select with possible options to match. that options have a value and a label. I don't think it is very difficult to match those automaticly. (even if its just the select with the option 'selected="selected" in TemplateColumn and SubMatchingSelect |
|
I agree on the hook part. but the mapping options on select can be selected by default if the value matches the index. and looking more to your code. the most is already done. but i guess that there is a incorrect check of settting the selected option by default on: i guess it should be - const value = options.find((opt) => opt.value == option.value)
+ const value = options.find((opt) => opt.value == option.entry) because If i do this, the default option is selected by default. |
I don't think anything is wrong with that code, your change would only work in your specific case and it's only a visual change - the data would still be wrong. If we wanted to add autoMatching for select fields, the config needs to be expanded for options to also have
And when select column is assigned here https://github.com/UgnisSoftware/react-spreadsheet-import/blob/master/src/steps/MatchColumnsStep/utils/setColumn.ts#L16 we need to add the same lavenstein logic as we do for column name matching here https://github.com/UgnisSoftware/react-spreadsheet-import/blob/master/src/steps/MatchColumnsStep/utils/getMatchedColumns.ts#L16 |
Seems a bit odd to set the same data in also, your interface SelectOption doenst have the property Back to the original request. If I have a xlsx with the data:
and a field with the select options:
its safe to say I want those fields auto matched to the right select options. right? |
|
Matching on value should be a great feature. matching on label didnt work either when i tested yesterday |
Also interested in this feature, this would be awesome, if you can merge this pull request |
We would also love to see this ! |
That feature would be amazing! |
Looking to validate state and country ISO codes and would also see value in this feature. 👍 |
Released in 4.4.0 - you will need to set autoMapSelectValues={true} - this flag will be set to true by default in the next major release, but I wanted to release it as a non-breaking change. Now with |
When I have a field that is a select with options. the values from the xlsx are not automaticly matched with the field options.
not on label, and not on value.
tried both, and even played with
selectHeaderStepHook
andmatchColumnsStepHook
but no success.fields:
options passed into the field:
tried both with typehinting it into a string and integer.
not matched:
any wat to automaticly match the values, based on label or value?
backgroud: we have several imports during the week. and between 10-20 product groups. and between 10-20 warehouse zones, its no fun to manually match these fields every import.
The text was updated successfully, but these errors were encountered: