Hello, I'm trying cascading fields with grid editing.
field="cmdtyCd" headerText="품목" width="200"
:allowEditing="false" :edit="cmdtyDropdown">
field="ordStndrd" headerText="규격" width="100"
:allowEditing="false" :edit="stndrdInput">
field="cmdtyOrdQty" headerText="주문수량" width="140"
:edit="cmdtyOrdQtyInput">
field="ordUnitNm" headerText="구매단위" width="100"
:allowEditing="false" :edit="ordUnitInput">
field="ordUnitCd" headerText="구매단위" width="100"
:allowEditing="false" :hidden="true" :edit="ordUnitCdInput">
field="ordqtyPerUnit" headerText="입수수량" width="100"
:allowEditing="false" :edit="ordqtyPerUnitInput">
field="ordTotQty" headerText="총수량" width="100"
:allowEditing="false" :edit="ordTotQtyInput">
field="invUnitNm" headerText="단위" width="100"
:allowEditing="false" :edit="invUnitInput">
field="buyPrice" headerText="단가" width="100"
:allowEditing="false" :edit="buyPriceInput">
field="cmdtySplAmt" headerText="공급가액" width="100"
:allowEditing="false" :edit="cmdtySplAmtInput">
field="cmdtyVatAmt" headerText="부가세" width="100"
:allowEditing="false" :edit="cmdtyTxInput">
field="cmdtyOrdAmt" headerText="주문금액" width="100"
:allowEditing="false" :edit="cmdtyOrdAmtInput">
field="taxSeNm" headerText="과세구분" width="100"
:allowEditing="false">
field="boMemo" headerText="비고" width="100">
let cmdtyDdElem, cmdtyDdObj
export const cmdtyDropdown = {
create: () => {
cmdtyDdElem = document.createElement('input')
return cmdtyDdElem
},
read: () => {
console.log('read', cmdtyDdObj)
return cmdtyDdObj.value
},
destroy: () => {
cmdtyDdObj.destroy()
},
write: (args) => {
console.log('write', args)
cmdtyDdObj = new DropDownList({
dataSource: store.getters.ordPsbCommodities,
fields: {
text: 'cmdtyNm',
value: 'cmdtyCd'
},
popupWidth: 400,
value: args.rowData.cmdtyCode || null,
itemTemplate: '[${cmdtyCd}] ${cmdtyNm}',
// valueTemplate: '${cmdtyNm}',
enabled: args.rowData.cmdtyCd ? false : true,
change: () => {
console.log('itemData', cmdtyDdObj.itemData)
// I tried to set value by this way.
stndrdInput.setValue(cmdtyDdObj.itemData)
ordUnitInput.setValue(cmdtyDdObj.itemData)
ordqtyPerUnitInput.setValue(cmdtyDdObj.itemData)
invUnitInput.setValue(cmdtyDdObj.itemData)
buyPriceInput.setValue(cmdtyDdObj.itemData)
cmdtyOrdQtyInput.activate(cmdtyDdObj.itemData)
// cmdtyCdInput.setCmdtyCd(cmdtyDdObj.itemData)
}
}, cmdtyDdElem)
}
}
|
// Grid’s actionBegin event handler
function actionBegin(args) {
if (args.requestType === "save") {
// Here you can get the entire row data in ‘args.data’
// So you can modify the values as per your requirement
args.data.CustomerID = "New_Value"
}
} |
|
// Grid instance
var gridObj = this.$refs.gridObj.ej2_instances[0];
// Pre-defined data to be set
var defaultVal = { "OrderID": 123, "CustomerID": "Avs", "Freight": 20 };
// Edit form elements are accessed and their values are updated by accessing the pre-defined data based on element name
[...gridObj.editModule.formObj.element.elements].forEach(function (ele, index) { ele.value = defaultVal[ele.name] }) |