ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: ohbayashi on April 03, 2017, 09:26:03 pm

Title: I want to change select.options in editorBegin, but it is not reflected.
Post by: ohbayashi on April 03, 2017, 09:26:03 pm
I want to change select.options in editorBegin, but it is not reflected.
How should the optimal coding be?

colModel ("ID1" to "ID4")
Code: [Select]
colModel = [
  { title: "ID1", dataIndx: "id1", editable: false },
  { title: "NM1", dataIndx: "name1",
    editor: {
      type: "select",
      labelIndx: "name",
      valueIndx: "id",
      prepend: { "": "-- select --" },
      options: [],
      mapIndices: { "id": id1, "name": name1 }
    }
   },
  { title: "ID2", dataIndx: "id2", editable: false },
  { title: "NM2", dataIndx: "name2" },
    editor: {
      type: "select",
      labelIndx: "name",
      valueIndx: "id",
      prepend: { "": "-- select --" },
      options: [],
      mapIndices: { "id": id2, "name": name2 }
    }
   },
]

Grid Events.
Code: [Select]
                editorBegin: function (evt, ui) {
                    this.showLoading();
                    var id = ui.dataIndx;
                    if (!id.match(/name[2-4]/)) { return };

                    var parentId = parseInt(id.replace(/name/g, "")) - 1,
                        val = ui.rowData["id" + parentId];
                    if (!val) { return };

                    var col = this.getColumn({ dataIndx: id });
                    $.getJSON("/api/names_select/" + val, function (dataJSON) {
                        col.editor.options = dataJSON.names;
                    })
                    // this.refreshCell({ dataIndx: id });
                },
Title: Re: I want to change select.options in editorBegin, but it is not reflected.
Post by: paramvir on April 04, 2017, 07:41:42 am
As of now, select list options can be set synchronously but not asynchronously after editor is created.

Please check this if you need to set select list options asynchronously before editor is created:

https://paramquery.com/pro/demos/edit_select

Please use autocomplete if you need to change options asynchronously after editor is created.

https://paramquery.com/pro/demos/editing_custom
Title: Re: I want to change select.options in editorBegin, but it is not reflected.
Post by: ohbayashi on April 06, 2017, 01:36:36 pm
We decided to correspond with before create.
Thank you.