After correction, the result is the same.
The code is as follows.
Thank you.
var orgdata = [
{ rivername: '한강', orgseq: '1', regdate: '2020-05-07', useyn:'1', riverseq:'1'},
{ rivername: '영산강', orgseq: '2', regdate: '2020-05-04', useyn:'1', riverseq:'1' }
];
obj.colModel = [
{ title: "강이름", width: 300, dataType: "string", align: "center", dataIndx: "rivername"},
{ title: "관리관청", width: 200, align: "center", dataIndx: "orgseq"
, editor: {
type:"select",
labelIndx: "orgname",
valueIndx: "orgseq",
//prepend: { "": "Default" }, // 선택이 없을 경우 처리 (예: 전체)
options: orglist
}
, render: function(ui){
var cellData = ui.cellData;
if (cellData != null && cellData != "") {
return orglist.find(function(item){
return item.orgseq == cellData;
}).orgname;
}
// else {
// ui.rowData.itemtype = "Default";
// return "Default";
// }
}
},
{ title: "등록일", width: 100, dataType: "string", align: "center", editable: false,dataIndx: "regdate" },
{ title: "사용여부", width: 20, dataType: "string", align: "center", editable: false,dataIndx: "useyn" },
{ title: "riverseq", width: 20, dataType: "int", align: "center", editable: false,dataIndx: "riverseq", hidden: true }
];
//called by add button in toolbar.
function addRow() {
var rowData = { rivername: '', orgseq: '1', regdate: '', useyn:'1', riverseq:'' }; //empty row template
//grid.addRow({newRow:rowData, rowIndx:0, history:true});
var rows = grid.getRowsByClass({ cls: 'pq-row-edit' });
if (rows.length > 0) {//already a row currently being edited.
var rowIndx = rows[0].rowIndx;
//focus on editor if any
grid.editFirstCellInRow({ rowIndx: rowIndx });
}
else {
//append empty row in the first row.
rowindex = grid.addRow({ rowIndxPage: 0, rowData: rowData, checkEditable: false });
//start editing the new row.
editRow();
}
viewButton(1); // type 0:init, 1: new, 2:modify
}
result:
pqgrid.dev.js:4823 Uncaught TypeError: Cannot read property 'length' of undefined
at t.paramquery.cRefresh.addRowIndx (pqgrid.dev.js:4823)
at e.<computed>.<computed>.<anonymous> (pqgrid.dev.js:4783)
at n (pqgrid.dev.js:402)
at e.<computed>.<computed>.e._trigger (pqgrid.dev.js:424)
at e.<computed>.<computed>.a.refreshDataFromDataModel (pqgrid.dev.js:2305)
at e.<computed>.<computed>.a.refreshView (pqgrid.dev.js:2468)
at e.<computed>.<computed>.n.addRow (pqgrid.dev.js:7309)
at addRow (orgriverlist.do:436)
at HTMLAnchorElement.onclick (VM1124 orgriverlist.do:180)