0

html

<lightning-checkbox-group name="Checkbox Group"
              data-id="check-box-group"
              label="Checkbox Group"
              options={options}
              value={selectedValues}
              onchange={handleChange}>
</lightning-checkbox-group>

js

handleGenerate(event){
    const searchKey = this.template.querySelector('[data-id="search-key"]').value;
    // const workItemType = this.template.querySelector('[data-id="check-box-group"]').value;
}
1
  • Your markup uses handleChange, your JS uses handleGenerate. Either you have a copy-paste issue, or you simply didn't call the right method, which would be the problem at hand. Commented May 16, 2021 at 3:43

1 Answer 1

1

In your code, you are invoking a handler method when your checkbox-group changes, in return, you are querying the element (from the parent) which is lightning-checkbox-group to get the value.

The lwc documentation for the checkbox-group is very precise on how you can get the value, so, I am not sure what it is you are attempting to do.

your handleChange method shoud get the value using the passed event as follows:

handleChange(e) {
        this.value = e.detail.value;
    }

I don't understand why you are attempting to use a querySelector.

2
  • but i was able to pass this from child to parent. below is search text value entered const searchKey = this.template.querySelector('[data-id="search-key"]').value Commented May 15, 2021 at 18:23
  • view updated answer. your post /question remains unclear... Commented May 19, 2021 at 5:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.