|
[App.Vue]
let surnameElem;
let surnameObj= new DropDownList()
let categoryElem
let categoryObj = new DropDownList();
surnamesParams: {
create: function () {
surnameElem = document.createElement('input')
return surnameElem
},
read: function () {
return surnameObj.value
},
destroy: function () {
surnameObj.destroy()
},
write: function () {
debugger;
surnameObj = new DropDownList({
dataSource: surnames,
fields: { value: 'id', text: 'name' },
change: function () {
const tempQuery = new Query().where('id', 'equal', surnameObj.value)
categoryObj.query = tempQuery
categoryObj.value = null
categoryObj.dataBind()
},
placeholder: 'Select a Surname',
floatLabelType: 'Never'
})
surnameObj.appendTo(surnameElem)
}
},
categoriesParams: {
create: function () {
categoryElem = document.createElement('input')
return categoryElem
},
read: function () {
return categoryObj.value
},
destroy: function () {
categoryObj.destroy()
},
write: function () {
debugger;
categoryObj = new DropDownList({
dataSource: categories,
fields: { value: 'id', text: 'name' },
placeholder: 'Select a Category',
floatLabelType: 'Never'
})
categoryObj.appendTo(categoryElem)
}
},
};
|
|
[App.Vue]
surnamesParams: {
create: function () {
surnameElem = document.createElement("input");
return surnameElem;
},
read: function () {
return surnameObj.value;
},
destroy: function () {
surnameObj.destroy();
},
write: function (args) {
debugger;
surnameObj = new DropDownList({
dataSource: surnames,
fields: { value: "id", text: "name" },
change: function () {
const tempQuery = new Query().where(
"id",
"equal",
surnameObj.value
);
categoryObj.query = tempQuery;
categoryObj.value = null;
categoryObj.dataBind();
},
floatLabelType: "Never",
});
surnameObj.value = args.rowData.surnameID;
surnameObj.appendTo(surnameElem);
},
},
categoriesParams: {
create: function () {
categoryElem = document.createElement("input");
return categoryElem;
},
read: function () {
return categoryObj.value;
},
destroy: function () {
categoryObj.destroy();
},
write: function () {
var query = categoryObj.query;
categoryObj = new DropDownList({
dataSource: categories,
fields: { value: "id", text: "name" },
placeholder: "Select a Category",
floatLabelType: "Never",
});
if (query) {
categoryObj.query = query;
}
categoryObj.appendTo(categoryElem);
},
}, |
|
[App.Vue]
<ejs-grid
id="Grid"
ref="grid"
height="400"
:dataSource="data"
:editSettings="editSettings"
:toolbar="toolbar"
:cellEdit="cellEdit"
>
<e-columns>
. . . .
</e-columns>
</ejs-grid>
surnamesParams: {
create: function () {
surnameElem = document.createElement("input");
return surnameElem;
},
read: function () {
return surnameObj.value;
},
destroy: function () {
surnameObj.destroy();
},
write: function (args) {
surnameObj = new DropDownList({
dataSource: surnames,
fields: { value: "id", text: "name" },
change: function (e) {
const tempQuery = new Query().where(
"id",
"equal",
surnameObj.value
);
this.parent.updateCell(
this.parent.getRowInfo(e.element).rowIndex,
"category",
null
); // Update the null value to category cell
categoryObj.query = tempQuery;
categoryObj.value = null;
categoryObj.dataBind();
}.bind(this),
floatLabelType: "Never",
});
surnameObj.value = args.rowData.surnameID;
surnameObj.appendTo(surnameElem);
},
},
. . . .
methods: {
cellEdit: function (e) {
if (e.columnName === "category" &&!e.cell.previousElementSibling.classList.contains("e-updatedtd")) {
e.cancel = true; // Prevent the edit action in category column
}
},
}, |
|
[App.Vue]
<ejs-grid
id="Grid"
ref="grid"
height="400"
:dataSource="data"
:editSettings="editSettings"
:toolbar="toolbar"
:cellEdit="cellEdit"
>
<e-columns>
<e-column field="id" headerText="ID" isPrimaryKey="true"></e-column>
<e-column
field="surnameID"
headerText="Surname"
type="string"
foreignKeyValue="name"
foreignKeyField="id"
:dataSource="surnames"
editType="dropdownedit"
:edit="surnamesParams"
></e-column>
<e-column
field="category"
headerText="Category"
type="string"
foreignKeyValue="name"
foreignKeyField="id"
:dataSource="categories"
editType="dropdownedit"
:edit="categoriesParams"
></e-column>
</e-columns>
</ejs-grid>
editSettings: {
allowEditing: true,
showConfirmDialog: false,
allowAdding: true,
allowDeleting: false,
mode: "Batch",
},
surnamesParams: {
create: function () {
surnameElem = document.createElement("input");
return surnameElem;
},
read: function () {
return surnameObj.value;
},
destroy: function () {
surnameObj.destroy();
},
write: function (args) {
surnameObj = new DropDownList({
dataSource: surnames,
fields: { value: "id", text: "name" },
change: function (e) {
const tempQuery = new Query().where(
"id",
"equal",
surnameObj.value
);
this.parent.updateCell(
this.parent.getRowInfo(e.element).rowIndex,
"category",
null
);
categoryObj.query = tempQuery;
categoryObj.value = null;
categoryObj.dataBind();
}.bind(this),
floatLabelType: "Never",
});
surnameObj.value = args.rowData.surnameID;
surnameObj.appendTo(surnameElem);
},
}, |