onChange(args) {
this.textareaObj.value = args.itemData.Game;
}
render() {
return (
<div class="row">
<div class="col-sm-2">
<DropDownListComponent
id="games"
dataSource={this.sportsData}
fields={this.fields}
change={this.onChange.bind(this)}
placeholder="Select a game"
floatLabelType="Auto"
/>
</div>
<div class="col-sm-2">
<TextBoxComponent
placeholder="Selected value in Textbox"
floatLabelType="Auto"
ref={scope => {
this.textareaObj = scope;
}}
/>
</div>
</div>
|
|
[index.js]
<GridComponent
id="gridcomp"
dataSource={data}
allowPaging={true}
ref={g => (this.gridInstance = g)}
pageSettings={{ pageCount: 5 }}
editSettings={this.editSettings}
>
<ColumnsDirective>
<ColumnDirective
field="OrderID"
headerText="Order ID"
width="120"
textAlign="Right"
isPrimaryKey={true}
validationRules={this.validationRule}
/>
. . . .
<ColumnDirective
field="ShipCountry"
edit={this.editparams}
headerText="Ship Country"
width="150"
/>
<ColumnDirective
field="ShipCity"
headerText="Ship City"
width="150"
/>
</ColumnsDirective>
editparams = {
create: () => {
this.elem = document.createElement("input");
return this.elem;
},
destroy: () => {
this.element.destroy();
},
read: args => {
return this.element.text;
},
write: args => {
this.element = new DropDownList({
floatLabelType: "Never",
fields: { text: "ShipCountry", value: "OrderID" },
dataSource: data,
placeholder: "Select a Value",
value: args.rowData["OrderID"],
change: function(e) {
const tempQuery = new Query().where("OrderID", "equal", e.value);
var findData = new DataManager(data).executeLocal(tempQuery);
console.log(findData);
var shipCityEle = [].slice
.call(this.gridInstance.editModule.formObj.inputElements)
.filter(x => x.getAttribute("name") == "ShipCity")[0];
shipCityEle.value = findData[0]["ShipCity"];
}.bind(this)
});
this.element.appendTo(this.elem);
}
};
|
[index.js]
this.shipCityParams = {
create: () => {
this.elem = document.createElement("input");
return this.elem;
},
destroy: () => {
this.element.destroy();
},
read: args => {
return this.element.text;
},
write: args => {
this.element = new DropDownList({
floatLabelType: "Never",
fields: { text: "ShipCountry", value: "OrderID" },
dataSource: orderDatas,
placeholder: "Select a Value",
value: args.rowData["OrderID"],
change: function(e) {
const tempQuery = new Query().where("OrderID", "equal", e.value);
var findData = new DataManager(
this.childGrid.dataSource
).executeLocal(tempQuery);
console.log(findData);
var gridInstance = e.element.closest(".e-grid").ej2_instances[0];
var shipCityEle = [].slice
.call(gridInstance.editModule.formObj.inputElements)
.forEach(item => {
switch (item.getAttribute("name")) {
case "ShipName":
item.value = findData[0]["ShipName"];
break;
case "OrderDate":
var intl = new Internationalization();
var dFormatter = intl.getDateFormat({ skeleton: "yMd" });
var formattedString = dFormatter(
new Date(findData[0]["OrderDate"])
);
item.ej2_instances[0].value = formattedString;
break;
}
});
}.bind(this)
});
this.element.appendTo(this.elem);
}
};
this.childGrid = {
dataSource: orderDatas,
queryString: "EmployeeID",
allowPaging: true,
pageSettings: { pageSize: 6, pageCount: 5 },
editSettings: {
allowAdding: true,
allowEditing: true,
allowDeleting: true
},
toolbar: ["Add", "Edit", "Delete", "Cancel", "Update"],
columns: [
{
field: "OrderID",
headerText: "Order ID",
textAlign: "Right",
isPrimaruKey: true,
width: 120
},
{
field: "ShipCity",
headerText: "Ship City",
edit: this.shipCityParams,
width: 120
},
{
field: "OrderDate",
headerText: "Order Date",
type: "date",
format: { skeleton: "yMd", type: "date" },
editType: "datepickeredit",
width: 120
},
{ field: "ShipName", headerText: "Ship Name", width: 150 },
{ field: "Freight", headerText: "Freight", width: 120 }
]
};
} |
[app.component.ts]
this.shipCityParams = {
create: () => {
this.elem = document.createElement("input");
return this.elem;
},
destroy: () => {
this.element.destroy();
},
read: args => {
return this.element.text;
},
write: args => {
var gridEle = args.row.closest(".e-grid");
var gridInstance = null;
if (gridEle) {
gridInstance = gridEle["ej2_instances"][0];
this.gridInstance = gridInstance;
}
this.element = new DropDownList({
floatLabelType: "Never",
fields: { text: "ShipCountry", value: "OrderID" },
dataSource: orderDatas,
placeholder: "Select a Value",
value: args.rowData["OrderID"],
change: function(e) {
const tempQuery = new Query().where("OrderID", "equal", e.value);
var findData = new DataManager(
this.childGrid.dataSource
).executeLocal(tempQuery);
console.log(findData);
var shipCityEle = [].slice
.call(this.gridInstance.editModule.formObj.inputElements)
.forEach(item => {
switch (item.getAttribute("name")) {
case "ShipName":
item.value = findData[0]["ShipName"];
break;
case "OrderDate":
var intl = new Internationalization();
var dFormatter = intl.getDateFormat({ skeleton: "yMd" });
var formattedString = dFormatter(
new Date(findData[0]["OrderDate"])
);
item.ej2_instances[0].value = formattedString;
break;
}
});
}.bind(this)
});
this.element.appendTo(this.elem);
}
}; |
[app.component.ts]
write: args => {
var dropdowndata = DataUtil.distinct(orderDatas, "OrderID", true);
this.element = new DropDownList({
floatLabelType: "Never",
fields: { text: "ShipCountry", value: "OrderID" },
dataSource: dropdowndata,
value: args.rowData["OrderID"],
change: function(e) {
const tempQuery = new Query().where("OrderID", "equal", e.value);
var findData = new DataManager(
this.childGrid.dataSource
).executeLocal(tempQuery);
console.log(findData);
var editform = e.element.closest(".e-gridform").ej2_instances[0];
var shipCityEle = [].slice
.call(editform.inputElements)
.forEach(item => {
switch (item.getAttribute("name")) {
case "ShipName":
item.value = findData[0]["ShipName"];
break;
case "OrderDate":
var intl = new Internationalization();
var dFormatter = intl.getDateFormat({ skeleton: "yMd" });
var formattedString = dFormatter(
new Date(findData[0]["OrderDate"])
);
item.ej2_instances[0].value = formattedString;
break;
}
});
}.bind(this)
});
this.element.appendTo(this.elem);
}
. . . .
actionBegin: function(args) {
if (args.requestType == "save" && args.action == "add") {
args.data[
this.parentDetails.parentKeyField
] = this.parentDetails.parentKeyFieldValue;
}
}, |