* colModel
{ title: "都道府県名", dataIndx: "prefecture", dataType: "string", minWidth: 140,
filter: {
type: "select",
condition: "equal",
prepend: { "": "-- select --" },
options: [],
},
editor: {
type: "select",
labelIndx: "prefecture",
valueIndx: "prefecture",
options: [],
dataMap: [ "prefecture", "city", "town", "zip_code" ]
},
* grid create.
create: function (evt, ui) {
// zipcodes load.
let grid = this;
$.ajax({
url: "/api/zipcodes/",
dataType: "json",
})
.then( // 1:success, 2:error
function (response) {
zipcodes = response.zipcodes;
},
function () {
$("#err_result").text("Data acquisition failed.");
}
)
.then(
function () {
// prefecture option set.
let column = grid.getColumn({ dataIndx: "prefecture" }),
keys = [],
opts = [];
zipcodes.forEach(function(row) {
if (keys.indexOf(row.prefecture) < 0) {
keys.push(row.prefecture);
opts.push({ prefecture: row.prefecture, city: null, town: null, zip_code: null });
// opts.push({ prefecture: row.prefecture });
}
})
column.filter.options = keys;
column.editor.options = opts;
}
* console.log
Uncaught incorrect usage of isValid dataIndx: city
_piv.isValidCell @ pqgrid.dev.js:3979
_piv.isValid @ pqgrid.dev.js:4060
fn.isValid @ pqgrid.dev.js:4045
fn._digestData @ pqgrid.dev.js:5536
fnGrid.updateRow @ pqgrid.dev.js:13546
fn.saveEditCell @ pqgrid.dev.js:5419
(anonymous) @ pqgrid.dev.js:6142
dispatch @ jquery-1.8.3.min.js:2
u @ jquery-1.8.3.min.js:2
trigger @ jquery-1.8.3.min.js:2
(anonymous) @ jquery-1.8.3.min.js:2
each @ jquery-1.8.3.min.js:2
each @ jquery-1.8.3.min.js:2
trigger @ jquery-1.8.3.min.js:2
v.fn.(anonymous function) @ jquery-1.8.3.min.js:2
fn.blurEditor @ pqgrid.dev.js:5208
fn._onContMouseDown @ pqgrid.dev.js:4216
(anonymous) @ pqgrid.dev.js:2661
dispatch @ jquery-1.8.3.min.js:2
u @ jquery-1.8.3.min.js:2