Author Topic: Clear the selected value in a dropdown  (Read 303 times)

cui

  • Newbie
  • *
  • Posts: 18
    • View Profile
Clear the selected value in a dropdown
« on: January 23, 2025, 06:58:14 am »
Hi,
I want to clear all selected conditions when I click the reset button. I have tried directly changing the value and then refreshing, but this approach closes the dropdown. I would like to reset the selection without closing the dropdown. How can I achieve this?

Code: [Select]
{
    title: '颜色编码',
    dataIndx: 'ColorCode',
    align: 'center',
    filter: {
      crules: [{ condition: 'range' }],
      selectGridObj: createSelectGridObj('ColorCode'),
      selectGridCreated(ui, ev) {
        ui.grid.$bottom[0].innerHTML = '<div class="pq-grid-footer"><div id="save">确定</div><div id="reset">reset</div></div>'
        let btn = document.getElementById('reset')
        btn.addEventListener('click', () => {
          ifRequest.value = true
          // console.error('rrrrrrrrrrr', ui.grid.pdata)
          // console.error('rrrrrrrrrrr', this)
        })
        let saveBtn = document.getElementById('save')
        saveBtn.addEventListener('click', () => {
          ifRequest.value = false
          const key = ui.labelIndx
          selectedArr[key].selectAllIo = $('#grid_json3').attr(`selectAllIo_${key}`) == 'true'
          this.refreshDataAndView()
          this.$filterpopup.remove()
        })
        ui.grid.on('check', (evt, ui) => {
          // this.hideLoading()
          ifRequest.value = true
        })
      },
      title(ui, column) {
        return titleFn(ui, column)
      },
    },
    filterFn(ui) {
      if (ui.condition == 'range') {
        ui.column.pq_title = '全部'
        return {
          attr: "placeholder='请选择' readonly",
        }
      }
    },
  },

Thank you very much for your assistance.

Best regards,
cui