os-js / osjs-dialogs

OS.js Dialogs Module

Home Page:https://manual.os-js.org/v3/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Latest value chosen in choice dialog!

miladhashemi opened this issue · comments

Hi,
Continued widget development(os-js/osjs-widgets#9), i faced new problem.
I kept a paramter as widget custom options.
measurment: 'netdata.apps.cpu.X'
Due to changing this custom option value I used choice dialog, but I don't know how should I use my parameter value as choice dialog default value.

createMeasurmentDialog() {
    this.core.make('osjs/dialog', 'choice', {
      title: 'Measurment',
      message: 'Select Measurment',
      //TODO: make this list via grafana service
      choices: {
        'netdata.apps.cpu.X': 'netdata.apps.cpu.X',
        'netdata.statsd_timer_swift.object_server.put.timing.events': 'netdata.statsd_timer_swift.object_server.put.timing.events'
      },
    }, (btn, value) => {
      if (btn === 'ok') {
        this.options.measurment = value;
        this.render();
        this.saveSettings();
      }
    });
  }

So, you want to be able to define the default value in the dropdown based on that option from your widget ?

If you update your @osjs/dialogs (version 3.0.20) you should now have a value: something option for the dialog to override the default value.