Set options dynamically of a choice column of a list control in inline editing mode

Hi!
I have a list control on my form, and it connects to a list which has a choice column. I set the list control to inline editing mode. When an item is edited the choice column shows the options set in the SharePoint list. However, I would like to have different options from the one set in the list. Can this be done with JavaScript?

I have tried experimentally the following, but did not work:

fd.control("SPDataTable1").$on("edit", function (editData) {
  console.dir(editData.field("editdata"));
  editData.field("ChoiceColumn").options = ["Option1", "Option2", "Option3"];
  editData.field("ChoiceColumn").widget.dataSource.options.data = ["Option1", "Option2", "Option3"];;
  editData.field("ChoiceColumn").widget.dataSource.transport.data = ["Option1", "Option2", "Option3"];;
  });

Thanks!

Hi @Janos_Nagy,

Could you share more on your use case? I'm not sure why you'd need different options from the ones specified in SharePoint. How do you intend to save the value if it doesn't align with the column settings of the list?

You can't directly modify the contents of a List or Library control, so it might be worth it to try changing the list itself with PnP JS.

Hi @IliaLazarevskii ,
Thanks for looking into this matter. I can save a different value to the choice field. Even if I could not than I would just allow the entering of new values in the field settings.
My use case is that I have dozens of options, from which I need to filter out values which are no longer valid. Also, in some cases I need to be able to add new names dynamically based on other values on the form.
Adding new options to a dropdown field of a DataTable control can be done, so I thought this may be done as well.

Hello @Janos_Nagy ,

think about using Plumsail field "Dropdown".
It can be dynamically filled in, but then you have to do something with the value. You can store is in the SharePoint text field as a text and when you again based on some conditions will load the data to control, load the text to the helper Plumsail field. :slight_smile:

I do it sometimes when someone needs something specific, "necessary".

Stepan

Thank you for the suggestion. I may go that route in the end.

1 Like