How to set value on the dropdown using js query?

Hey, I try to set the dropdown value in runtime using js query but values are not showing on the dropdown.
I'm using the setValue() function for this.

the dropdown field is inside the listview.

listview1->listview2->dropdown

How are trying to populate the drop-down? Can you share the code?

@ScottR

let finalJson = {}
let children = itemContainerListView.data;
let childJson = children.map((x, index) => {
  let inputArr = listView1[index].data.map(y => y)
  return {
    child: index + 1,
    title: inputComponentTitle[index].value,
    jsonData: inputArr
  }
});
for (let i = 0; i < childJson.length; i++) {
  let header = childJson[i].title;
  let mapped_keys = mappedkeyList.data;
  let key_list = keyList.data;
  let jsonData = childJson[i].jsonData;
  let key_data = []
  for (let j = 0; j < jsonData.length; j++) {
    if (header != "") {
      console.log(header)
      if (mapped_keys != "" && mapped_keys.length > 0) {
        console.log(mapped_keys.length)
        for (let mI = 0; mI < mapped_keys.length; mI++) {
          if (mapped_keys[mI].component_id == header) {
            let key_id = mapped_keys[mI].key_id;
            if (key_list != "" && key_list.length > 0) {
              for (let kJ = 0; kJ < key_list.length; kJ++) {
                if (key_id == key_list[kJ]._id) {
                  key_data.push({
                    "lable": key_list[kJ]._id,
                    "value": key_list[kJ].key_name
                  });
                }
              }
              let parent_Key = parentKey[i][j].value;
              let data_type = dataTypes.data
              if (parent_Key != '') {
                let data_type_id = "";
                for (let cK = 0; cK < key_list.length; cK++) {
                  if (key_list[cK]._id == parent_Key) {
                    data_type_id = key_list[cK].data_type_id;
                    break;
                  }
                }
                let d_type = ""
                const index = data_type.findIndex((type) => type._id == data_type_id);
                if (index != -1) {
                  d_type = data_type[index].data_type
                }
                if (datatype[i][j] != "") {
                  datatype[i][j].setValue(d_type)
                }
              }
            }
          }
        }
      }
      console.log(i, j)
      console.log(key_data)
      parentKey[i][j].setValue(key_data)
    }

  }

}

Hey @ScottR
[{lable:"XYZ",value:1},{lable:"abc",value:2}]
this value I want to set this as options on the dropdown.

inputComponentTitle.setValue([{"lable":"xyz","value":1},{"lable":"abx","value":2}])

and this is the code that I am trying.
it's just is an example value.

SetValue should not need the [ and ]
Also curly brackets should like {{ and }} you only have one each

can you format the code using the below code how actually it is?

inputComponentTitle.setValue([{"lable":"xyz","value":1},{"lable":"abx","value":2}])

Hey @Pradip_Kumar_Parkar!

Since inputComponentTitle is nested in a listview can you try indexing it before setting the value? e.g.

[{"lable":"xyz","value":1},{"lable":"abx","value":2}].forEach((item, index) => inputComponentTitle[index].setValue(item.value))

If your component is two layers deep you might need to do something like

yourComponent[index1][index2].setValue(value)

Let me know if that works!