How to add select all option in form multiselect component. i am passing data as object with country code & country name for the component
1 Answer, 1 is accepted
0
Wissam
Telerik team
answered on 30 Oct 2023, 12:41 PM
Hello, Abhishek,
We have a Knowledge Base article that implements selecting all the items using a `Select All` option. It also renders a checkbox element next to each item using the itemRender property but you can remove it if it is not required in your use case scenario:
Hi Wissam, thank you for the info. I am looking for select all option in FormMultiselect Component. Kindly help
Wissam
Telerik team
commented on 01 Nov 2023, 11:47 AM
Hi, Abhishek,
I prepared an example of the MultiSelect component with the select all option in the KendoReact Form.
This approach requires handling the `onChange` coming from the `fieldRenderProps` in the `onChange` handler of the MultiSelect component, where you can set the value in the event to the calculated value:
fieldRenderProps.onChange({
target: event.target,
value: { value },
});
In addition, the you should pass `state.value` to the MultiSelect component instead of the value coming from the fieldRenderProps. Therefore, I am setting the value under `{...others}`:
Moreover, I could see that you submitted a feature request for the same question. Therefore, I will delete it in order to keep the information consistent:
I am looking for example which has the response with key value pair. in the above mentioned example we have only country name. In my case, i have both country name & country code
Wissam
Telerik team
commented on 10 Nov 2023, 06:06 AM
Hello, Abhishek,
Thank you for getting back to me with more information.
I believe that you are binding the MultiSelect data to a dataset of objects. Is this correct?
I updated the example such that I am setting the data to an array of objects, and in `handleChange`, in the first two lines I changed `i` to `i.text` since the `i` now refers to the object that contains the text and id properties. In addition, I added the `textField` and `dataItemKey` properties to the MultiSelect component: