Skip to content

Commit

Permalink
Fix selections in Tables (#215)
Browse files Browse the repository at this point in the history
* Fix selections aren't working in Tables

* Fixed single selections aren't working in Table

---------

Co-authored-by: Vishal <vishal.sharma@in.pega.com>
  • Loading branch information
vishalshrm539 and Vishal authored Oct 29, 2024
1 parent ec002f1 commit 110011b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/templates/ListView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ListView extends BridgeBase {
rowID: any;
response: any;
compositeKeys: any;
selectedValues: any;
constructor() {
// Note: BridgeBase constructor has 2 optional args:
// 1st: inDebug - sets this.bLogging: false if not provided
Expand Down Expand Up @@ -110,6 +111,9 @@ class ListView extends BridgeBase {
this.compositeKeys = theConfigProps?.compositeKeys;
this.rowID = this.compositeKeys && this.compositeKeys?.length === 1 ? this.compositeKeys[0] : defRowID;

this.selectedValue = theConfigProps.value;
this.selectedValues = theConfigProps.readonlyContextList;

// const componentConfig = this.thePConn.getRawMetadata().config;
// const refList = theConfigProps.referenceList;
this.searchIcon = Utils.getImageSrc('search', Utils.getSDKStaticContentUrl());
Expand Down Expand Up @@ -353,13 +357,15 @@ class ListView extends BridgeBase {
}

private radioRender: GridColumnBodyLitRenderer<any> = row => {
const rowID = row[this.rowID];
return html`<input name="radio-buttons" type="radio" .value="${rowID}" @change="${this.onRadioChange}" />`;
const rowValue = row[this.rowID];
const isRowSelected = rowValue === this.selectedValue;
return html`<input name="radio-buttons" type="radio" .value="${rowValue}" ?checked=${isRowSelected} @change="${this.onRadioChange}" />`;
};

private checkboxRender: GridColumnBodyLitRenderer<any> = row => {
const rowID = row[this.rowID];
return html`<input name="checkbox" type="checkbox" .value="${rowID}" @change="${this.onCheckboxClick}" />`;
const rowValue = row[this.rowID];
const isRowSelected = this.selectedValues.some(selectedValue => selectedValue[this.rowID] === rowValue);
return html`<input name="checkbox" type="checkbox" .value="${rowValue}" ?checked=${isRowSelected} @change="${this.onCheckboxClick}" />`;
};

onRadioChange(event) {
Expand Down

0 comments on commit 110011b

Please sign in to comment.