Fixed #1755 - New selectionMode for PickList
parent
67a7799558
commit
4f246b64e4
|
@ -11,6 +11,12 @@ const PickListProps = [
|
||||||
default: "null",
|
default: "null",
|
||||||
description: "Selected items in the list as a multidimensional array."
|
description: "Selected items in the list as a multidimensional array."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "selectionMode",
|
||||||
|
type: "string",
|
||||||
|
default: "null",
|
||||||
|
description: 'Defines selection mode, options are "single" and "multiple".'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "metaKeySelection",
|
name: "metaKeySelection",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { VNode } from 'vue';
|
||||||
interface PickListProps {
|
interface PickListProps {
|
||||||
modelValue?: any[][];
|
modelValue?: any[][];
|
||||||
selection?: any[][];
|
selection?: any[][];
|
||||||
|
selectionMode?: string;
|
||||||
dataKey?: string;
|
dataKey?: string;
|
||||||
metaKeySelection?: boolean;
|
metaKeySelection?: boolean;
|
||||||
listStyle?: any;
|
listStyle?: any;
|
||||||
|
|
|
@ -66,6 +66,10 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [[],[]]
|
default: () => [[],[]]
|
||||||
},
|
},
|
||||||
|
selectionMode: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
dataKey: {
|
dataKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
|
@ -381,19 +385,20 @@ export default {
|
||||||
_selection = selectionList.filter((val, index) => index !== selectedIndex);
|
_selection = selectionList.filter((val, index) => index !== selectedIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_selection = (metaKey) ? selectionList ? [...selectionList] : [] : [];
|
if (metaKey) {
|
||||||
|
_selection = this.isMultipleSelectionMode() ? selectionList ? [...selectionList] : [] : [];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_selection = [];
|
||||||
|
}
|
||||||
|
|
||||||
_selection.push(item);
|
_selection.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (selected) {
|
_selection = this.isMultipleSelectionMode() ? selectionList ? [...selectionList] : [] : [];
|
||||||
_selection = selectionList.filter((val, index) => index !== selectedIndex);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_selection = selectionList ? [...selectionList] : [];
|
|
||||||
_selection.push(item);
|
_selection.push(item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let newSelection = [...this.d_selection];
|
let newSelection = [...this.d_selection];
|
||||||
newSelection[listIndex] = _selection;
|
newSelection[listIndex] = _selection;
|
||||||
|
@ -543,6 +548,12 @@ export default {
|
||||||
document.head.removeChild(this.styleElement);
|
document.head.removeChild(this.styleElement);
|
||||||
this.styleElement = null;
|
this.styleElement = null;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isSingleSelectionMode() {
|
||||||
|
return this.selectionMode === 'single';
|
||||||
|
},
|
||||||
|
isMultipleSelectionMode() {
|
||||||
|
return this.selectionMode === 'multiple';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -102,6 +102,12 @@ import PickList from 'primevue/picklist';
|
||||||
<td>null</td>
|
<td>null</td>
|
||||||
<td>Selected items in the list as a multidimensional array.</td>
|
<td>Selected items in the list as a multidimensional array.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>selectionMode</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Defines selection mode, options are "single" and "multiple".</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>metaKeySelection</td>
|
<td>metaKeySelection</td>
|
||||||
<td>boolean</td>
|
<td>boolean</td>
|
||||||
|
|
Loading…
Reference in New Issue