Add sort configuration
This commit is contained in:
parent
0fbb1b6f4c
commit
6bebb90d92
|
@ -35,6 +35,8 @@ export interface IReactAccordionWebPartProps {
|
||||||
allowMultipleExpanded: boolean;
|
allowMultipleExpanded: boolean;
|
||||||
accordianTitleColumn: string;
|
accordianTitleColumn: string;
|
||||||
accordianContentColumn: string;
|
accordianContentColumn: string;
|
||||||
|
accordianSortColumn: string;
|
||||||
|
isSortDescending: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ReactAccordionWebPart extends BaseClientSideWebPart<
|
export default class ReactAccordionWebPart extends BaseClientSideWebPart<
|
||||||
|
@ -65,6 +67,8 @@ export default class ReactAccordionWebPart extends BaseClientSideWebPart<
|
||||||
accordionTitle: this.properties.accordionTitle,
|
accordionTitle: this.properties.accordionTitle,
|
||||||
accordianTitleColumn: this.properties.accordianTitleColumn,
|
accordianTitleColumn: this.properties.accordianTitleColumn,
|
||||||
accordianContentColumn: this.properties.accordianContentColumn,
|
accordianContentColumn: this.properties.accordianContentColumn,
|
||||||
|
accordianSortColumn: this.properties.accordianSortColumn,
|
||||||
|
isSortDescending: this.properties.isSortDescending,
|
||||||
allowZeroExpanded: this.properties.allowZeroExpanded,
|
allowZeroExpanded: this.properties.allowZeroExpanded,
|
||||||
allowMultipleExpanded: this.properties.allowMultipleExpanded,
|
allowMultipleExpanded: this.properties.allowMultipleExpanded,
|
||||||
displayMode: this.displayMode,
|
displayMode: this.displayMode,
|
||||||
|
@ -342,6 +346,17 @@ export default class ReactAccordionWebPart extends BaseClientSideWebPart<
|
||||||
options: this.allListColumns,
|
options: this.allListColumns,
|
||||||
disabled: this.choicesDropdownDisabled,
|
disabled: this.choicesDropdownDisabled,
|
||||||
}),
|
}),
|
||||||
|
PropertyPaneDropdown("accordianSortColumn", {
|
||||||
|
label: "Select the Column for Accordion Sort Rows.",
|
||||||
|
options: this.allListColumns,
|
||||||
|
disabled: this.choicesDropdownDisabled,
|
||||||
|
}),
|
||||||
|
PropertyPaneToggle("isSortDescending", {
|
||||||
|
label: "Sort type",
|
||||||
|
onText: "Descending",
|
||||||
|
offText: "Ascending",
|
||||||
|
disabled: !this.properties.accordianSortColumn
|
||||||
|
}),
|
||||||
PropertyPaneToggle("allowZeroExpanded", {
|
PropertyPaneToggle("allowZeroExpanded", {
|
||||||
label: "Allow zero expanded",
|
label: "Allow zero expanded",
|
||||||
checked: this.properties.allowZeroExpanded,
|
checked: this.properties.allowZeroExpanded,
|
||||||
|
|
|
@ -7,6 +7,8 @@ export interface IReactAccordionProps {
|
||||||
selectedChoice: string;
|
selectedChoice: string;
|
||||||
accordianTitleColumn: string;
|
accordianTitleColumn: string;
|
||||||
accordianContentColumn: string;
|
accordianContentColumn: string;
|
||||||
|
accordianSortColumn: string;
|
||||||
|
isSortDescending: boolean;
|
||||||
allowZeroExpanded: boolean;
|
allowZeroExpanded: boolean;
|
||||||
allowMultipleExpanded: boolean;
|
allowMultipleExpanded: boolean;
|
||||||
displayMode: DisplayMode;
|
displayMode: DisplayMode;
|
||||||
|
|
|
@ -46,12 +46,24 @@ export default class ReactAccordion extends React.Component<
|
||||||
typeof this.props.selectedChoice !== "undefined" &&
|
typeof this.props.selectedChoice !== "undefined" &&
|
||||||
this.props.selectedChoice.length > 0
|
this.props.selectedChoice.length > 0
|
||||||
) {
|
) {
|
||||||
let query =
|
let orderByQuery = '';
|
||||||
"<View><Query><Where><Eq><FieldRef Name='" +
|
if (this.props.accordianSortColumn) {
|
||||||
this.props.columnTitle +
|
orderByQuery = `<OrderBy>
|
||||||
"'/><Value Type='Text'>" +
|
<FieldRef Name='${this.props.accordianSortColumn}' ${this.props.isSortDescending ? 'Ascending="False"' : ''} />
|
||||||
this.props.selectedChoice +
|
</OrderBy>`;
|
||||||
"</Value></Eq></Where></Query></View>";
|
}
|
||||||
|
|
||||||
|
let query = `<View>
|
||||||
|
<Query>
|
||||||
|
<Where>
|
||||||
|
<Eq>
|
||||||
|
<FieldRef Name='${this.props.columnTitle}'/>
|
||||||
|
<Value Type='Text'>${this.props.selectedChoice}</Value>
|
||||||
|
</Eq>
|
||||||
|
</Where>
|
||||||
|
${orderByQuery}
|
||||||
|
</Query>
|
||||||
|
</View>`;
|
||||||
|
|
||||||
let theAccordianList = sp.web.lists.getById(this.props.listId);
|
let theAccordianList = sp.web.lists.getById(this.props.listId);
|
||||||
theAccordianList
|
theAccordianList
|
||||||
|
|
Loading…
Reference in New Issue