Experimental combobox, pagination

This commit is contained in:
Erki Aas 2022-10-11 02:50:03 +03:00
parent 274620c994
commit b2439a7a49
2 changed files with 61 additions and 13 deletions

View File

@ -0,0 +1,37 @@
export default {
template: `
<span>
<select v-model="currentValue" style="width: 100px"
>
<option v-for="option in options">
{{ option }}
</option>
<option value=""/>
</select>
</span>
`,
data: function () {
return {
options: [],
currentValue: null,
};
},
watch: {
currentValue (newValue) {
this.params.parentFilterInstance((instance) => {
instance.onFloatingFilterChanged('', newValue);
});
}
},
methods: {
onParentModelChanged(parentModel) {
this.options = this.params.column.colDef.floatingFilterComponentParams.options
// When the filter is empty we will receive a null value here
if (!parentModel) {
this.currentValue = '';
} else {
this.currentValue = parentModel.filter;
}
}
},
};

View File

@ -6,10 +6,11 @@
@grid-ready="onGridReady" @grid-ready="onGridReady"
:defaultColDef="defaultColDef" :defaultColDef="defaultColDef"
:columnDefs="columnDefs" :columnDefs="columnDefs"
:pagination="true"
:paginationAutoPageSize=true
:row-data="null" :row-data="null"
:supress-horisontal-scroll="true" :supress-horisontal-scroll="true"
:enable-scrolling="true" :enable-scrolling="true"
:get-row-id="(params) => params.data.index"
></ag-grid-vue> ></ag-grid-vue>
</div> </div>
</template> </template>
@ -19,12 +20,26 @@ import { AgGridVue } from "ag-grid-vue3";
import "ag-grid-community/styles//ag-grid.css"; import "ag-grid-community/styles//ag-grid.css";
import "ag-grid-community/styles//ag-theme-alpine.css"; import "ag-grid-community/styles//ag-theme-alpine.css";
import ScreenshotCell from "./ScreenshotCell.js"; import ScreenshotCell from "./ScreenshotCell.js";
import {watchEffect} from "vue"; import ComboboxFilter from './ComboboxFilter.js';
const comboBoxDefinition = () => {
return {
filter: true,
floatingFilter: true,
suppressMenu: true,
floatingFilterComponent: 'ComboboxFilter',
floatingFilterComponentParams: {
suppressFilterButton: true,
options: []
},
}
};
export default { export default {
components: { components: {
AgGridVue, AgGridVue,
ScreenshotCell: ScreenshotCell, ScreenshotCell: ScreenshotCell,
ComboboxFilter
}, },
data() { data() {
return { return {
@ -34,9 +49,8 @@ export default {
defaultColDef: { defaultColDef: {
width: 50, width: 50,
initialPinned: true, initialPinned: true,
filter: true,
floatingFilter: true,
resizable: true, resizable: true,
editable: true
}, },
currentRowCount: 0, currentRowCount: 0,
viewRowCount: 20, viewRowCount: 20,
@ -48,6 +62,7 @@ export default {
{ {
field: 'kubernetes.namespace', field: 'kubernetes.namespace',
headerName: 'namespace', headerName: 'namespace',
...comboBoxDefinition(),
}, },
{ {
field: 'kubernetes.pod.name', field: 'kubernetes.pod.name',
@ -101,19 +116,15 @@ export default {
this.gridApi = params.api; this.gridApi = params.api;
this.gridColumnApi = params.columnApi; this.gridColumnApi = params.columnApi;
const timer = setInterval(() => { const timer = setInterval(() => {
this.refreshRowData(); this.getComboBoxOptions();
}, 1000); }, 3000);
}, },
handleReceiveMessage (event) { handleReceiveMessage (event) {
const eventData = this.parseEventData(event.data); const eventData = this.parseEventData(event.data);
eventData.index = this.currentRowCount this.rowData.push(eventData)
// this.rowData.unshift(eventData) this.gridApi.setRowData(this.rowData)
if (this.currentRowCount < this.viewRowCount) {
this.gridApi.setRowData(this.rowData)
this.currentRowCount = this.currentRowCount + 1
}
this.gridApi.sizeColumnsToFit() this.gridApi.sizeColumnsToFit()
this.getComboBoxOptions()
}, },
refreshRowData () { refreshRowData () {
const itemsToUpdate = []; const itemsToUpdate = [];