<template>
<div id="app">
<ejs-grid
:dataSource="data"
:editSettings="editSettings"
:toolbar="toolbar"
height="273px"
>
<e-columns>
<e-column
field="OrderID"
headerText="Order ID"
textAlign="Right"
:isPrimaryKey="true"
width="100"
></e-column>
<e-column
field="CustomerID"
headerText="Customer ID"
width="120"
></e-column>
<e-column
field="ShipCountry"
headerText="Ship Country"
:edit="autocomParams"
width="150"
></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
----
let elem;
let autocompleteObj;
export default {
data() {
return {
data: data,
editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
},
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"],
// create the cell edit control
autocomParams: {
create: function () {
elem = document.createElement("input");
return elem;
},
read: () => {
return autocompleteObj.value; // returned value will be bound in Grid
},
destroy: () => {
autocompleteObj.destroy();
},
write: (args) => {
autocompleteObj = new AutoComplete({
// bind the Data to datasource property
dataSource: new DataManager({
url:
adaptor: new ODataV4Adaptor(),
crossDomain: true,
}),
// value: args.rowData[args.column.field],
// maps the appropriate column to fields property
fields: { field: "ShipCountry", value: "ShipCountry" },
//set the placeholder to AutoComplete input
placeholder: "Find a Country",
});
autocompleteObj.appendTo(elem);
},
},
};
},
provide: {
grid: [Page, Edit, Toolbar],
},
};
</script>
|
[App.vue]
autocomParams: {
create: function () {
elem = document.createElement("input");
return elem;
},
read: () => {
return autocompleteObj.value;
},
destroy: () => {
autocompleteObj.destroy();
},
write: (args) => {
autocompleteObj = new AutoComplete({
// bind the Data to datasource property
dataSource: new DataManager({
adaptor: new ODataV4Adaptor(),
crossDomain: true,
}),
// bind the cell value to the autoComplete control
value: args.rowData[args.column.field], // it request top 20 records based on the cell value
// maps the appropriate column to fields property
fields: { field: "ShipCountry", value: "ShipCountry" },
//set the placeholder to AutoComplete input
placeholder: "Find a Country",
});
autocompleteObj.appendTo(elem);
},
},
};
|