Hoppa till huvudinnehållet

ListBox get selected items

Kommentarer

8 kommentarer

  • Stefan Schweigert

    Hello Will,

     

    Yes, currently that's the best way to interact with the elements within a ListBox. I will create a feature request for making this process easier.

     

    Thanks, Stefan

    0
  • Permanently deleted user

    Will, do you have a sample in how you accomplished this? I get casting errors when trying to establish the Foreach loop as it requires an IEnumerable.

     

    The other issue is the Listbox is local to the form and it would be useful to set it's scope broader than that

    0
  • Permanently deleted user

    Do we have any update on the method of retrieving selected values from a Listbox yet? Or is the method described by Will still the best option for now?

    0
  • Stefan Schweigert

    Hi Jie,

     

    This is currently the only method to retrieve the values from a List Box. If you look at the Samples - List Box and Samples - Loop Through Features in a Feature Set workflow samples and combine the two processes, that should allow you to access the values.

     

    Thanks, Stefan

    0
  • Permanently deleted user

    Hi Stefan,

     

    Thanks for the confirmation! I have figured out how to get the selected values through the looping process.

     

    Thanks,

    Jie?

    0
  • Amanda Putri

    Hello, is there any most current update on this function? 

    I am using a listbox in my workflow and would like to get the selected items to be used in a subsequent activity (Run Report based on the selected features IDs). If someone could please point me to the right direction that'd be great! 

    At the moment, I use Create Value within the Change subworkflow in the ListBox component and have this as input: = `OBJECTID = '${$ACTGridgeomform.state.listBox2.value.items}'` but got the error [object Object].

    Thank you!

     

     

    0
  • Ken Lyon

    Amanda Putri You're along the right lines. The list box's value is an ItemsRef, which contains an array of selected items in its items property. 

    You are seeing “[object Object]” because it's trying to convert an array of items to a string. If you're sure there's only one selected, you could change your expression to this:

    = `OBJECTID = '${$ACTGridgeomform.state.listBox2.value.items[0].value}'`

    However, if there was more than one selected, you would likely need something like this:

    = `OBJECTID IN (${$ACTGridgeomform.state.listBox2.value.items.map(i => `'${i.value}'`).join(",")})`

    The .map() function will return an array of the values of the selected items with single quotes around them.

    The .join() function will convert the array of values into a string with commas between them.

    If your expression is being used in a SQL Query, the OBJECTID IN ('a', ‘b’, ‘c’) syntax should return all rows where the OBJECTID is one of the values listed.

    If you find “OBJECTID IN ()” does not work in your situation, you might need to adapt it to produce an expression like “OBJECTID = ‘a’ OR OBJECTID = ‘b’ OR OBJECTID = ‘c’".

    0
  • Amanda Putri

    Hi Ken Lyon, thanks for your response! I managed to get the item list using this as input in Create Value activity: =$ACTGridgeomform.state.listBox2.value.items.map(x => x.value.data.attributes.OBJECTID).

    One thing I also missed previously was that I did not specify OBJECTID as one of the Output Fields in the Query Layer. I put the Query Layer within the Change event for the Geometry Picker which then feed the ListBox.

    Cheers. 

     

    0

Du måste logga in om du vill lämna en kommentar.