<vxe-column field="fixed" title="列固定" width="110" :cell-render="fixedEditRender" ></vxe-column> fixedEditRender是下拉列表 怎么监听 下拉列表选择的值
时间: 2024-12-12 11:16:14 浏览: 38
`fixedEditRender` 函数通常用于 Vue 的 VXE 表格组件中,作为单元格渲染函数,当列设置为 `fixed` 并且需要用户从下拉列表中选择值时,你可以创建一个自定义的渲染组件,并通过事件监听来获取用户的选择。
首先,你需要创建一个下拉列表组件,例如使用 Vue 的 `<select>` 元素:
```html
<template>
<div @change="handleSelectChange">
<select v-model="selectedValue">
<option v-for="(item, index) in options" :key="index" :value="item.value">{{ item.label }}</option>
</select>
</div>
</template>
<script>
export default {
props: ['options', 'selectedValue'], // 接收父组件传递的数据
methods: {
handleSelectChange(e) {
this.$emit('input', e.target.value); // 当选项改变时,触发 'input' 事件并传递所选值
}
}
}
</script>
```
然后,在 `fixedEditRender` 中,将这个下拉列表作为内容,并绑定 `options` 和 `selectedValue` 到相应的 prop:
```vue
methods: {
fixedEditRender(row, cell, column) {
return {
component: {
// 使用我们之前定义的下拉列表组件
functionalComponent: YourDropdownComponent,
props: { options: this.dropdownOptions, selectedValue: cell.value }, // 传入数据
},
events: {
input(value) { // 监听输入事件,即下拉列表的选择
this.$emit(column.field, value); // 触发父组件指定的字段更新事件
}
}
};
},
},
```
记得替换 `YourDropdownComponent` 为你的实际组件名,并确保你在父组件上绑定了正确的事件处理函数,比如 `update:field-fixed` 来接收并处理 `fixed` 列的选择。
阅读全文
相关推荐

















<a-form-item label="检验检测明细" v-bind="validateInfos.miEtmInspectPlanItemList" :labelCol="{ xs: { span: 5 }, sm: { span: 2 } }" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" > <j-vxe-table ref="planItemListRef" key="id" :keep-source="true" resizable bordered :columns="planItemListColumns" :dataSource="formData.miEtmInspectPlanItemList" :height="340" :disabled="disabled" :rowSelection="false" :asyncRemove="true" :toolbar-config="{ slots: ['prefix', 'suffix'], btns: [] }" :toolbar="!disabled" > <template #toolbarSuffix="props"> <a-button type="primary" @click="selectPlanItem">新增</a-button> </template> <template #action="props" v-if="!disabled"> 删除 </template> </j-vxe-table> <ledger-select-modal :defaultFullscreen="true" rowKey="id" @register="registerPlanItemModal" @get-select-result="onSelectPlanItemOk" /> </a-form-item>

