onPopupOpen(args: PopupOpenEventArgs): void {
let clientsMapped = this.clients.map(client=> { return {text:client.company, value:client.company}; })
if (args.type === 'Editor') {
// Create required custom elements in initial time
if (!args.element.querySelector('.custom-field-row')) {
let row: HTMLElement = createElement('div', {className: 'custom-field-row'});
let formElement: HTMLElement = args.element.querySelector('.e-schedule-form');
formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
let container: HTMLElement = createElement('div', {className: 'custom-field-container'});
let inputEle: HTMLInputElement = createElement('input', {
className: 'e-field', attrs: {name: 'Client'}
}) as HTMLInputElement;
container.appendChild(inputEle);
let row2: HTMLElement = createElement('div', {className: 'custom-field-row'});
let formElement2: HTMLElement = args.element.querySelector('.e-schedule-form');
formElement2.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
let container2: HTMLElement = createElement('div', {className: 'custom-field-container'});
let inputEle2: HTMLInputElement = createElement('input', {
className: 'e-field', attrs: {name: 'distance'}
}) as HTMLInputElement;
container.appendChild(inputEle2);
row.appendChild(container);
row2.appendChild(container2);
let dropDownList: DropDownList = new DropDownList({
dataSource: clientsMapped,
fields: {text: 'text', value: 'value'},
value: (<{ [key: string]: Object }>(args.data)).Client as string,
floatLabelType: 'Always', placeholder: 'Client'
});
dropDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'Client');
let distanceTextBox: NumericTextBox = new NumericTextBox({
value: 88,
floatLabelType: 'Auto', placeholder: 'Distance in KM'
//enableRtl: true
});
distanceTextBox.appendTo(inputEle2);
inputEle2.setAttribute('name', 'km');
}
}
}
I want, by making use of the ActionComplete method, use the selected client to pass an object to the back end like this:
const object= {
createdBy: this.userName.username,
client: *here I want the selected user from the Dropdown list*
distance: *here i want the value of distance*,
};If you need some more information please let me know. Thanks in advance
|
private dataManger: DataManager = new DataManager({
url: 'http://localhost:54738/Home/LoadData',
crudUrl: 'http://localhost:54738/Home/UpdateData',
crossDomain: true,
adaptor: new UrlAdaptor
});
public eventSettings: EventSettingsModel = { dataSource: this.dataManger }; |
onPopupOpen(args: PopupOpenEventArgs): void {
let clientsMapped = this.clients.map(client=> { return {text:client.company, value:client.company}; })
if (args.type === 'Editor') {
// Create required custom elements in initial time
if (!args.element.querySelector('.custom-field-row' )) {
let row: HTMLElement = createElement('div', {className: 'custom-field-row'});
let formElement: HTMLElement = args.element.querySelector('.e-schedule-form' );
formElement.firstChild.insertBefore (row, args.element.querySelector('.e-title-location-row' ));
let container: HTMLElement = createElement('div', {className: 'custom-field-container'});
let inputEle: HTMLInputElement = createElement('input', {
className: 'e-field', attrs: {name: 'Client'}
}) as HTMLInputElement;
container.appendChild(inputEle);
let row2: HTMLElement = createElement('div', {className: 'custom-field-row'});
let formElement2: HTMLElement = args.element.querySelector('.e-schedule-form' );
formElement2.firstChild.insertBefore (row, args.element.querySelector('.e-title-location-row' ));
let container2: HTMLElement = createElement('div', {className: 'custom-field-container'});
let inputEle2: HTMLInputElement = createElement('input', {
className: 'e-field', attrs: {name: 'distance'}
}) as HTMLInputElement;
container.appendChild(inputEle2 );
row.appendChild(container);
row2.appendChild(container2);
let dropDownList: DropDownList = new DropDownList({
dataSource: clientsMapped,
fields: {text: 'text', value: 'value'},
value: (<{ [key: string]: Object }>(args.data)).Client as string,
floatLabelType: 'Always', placeholder: 'Client'
});
dropDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'Client');
let distanceTextBox: NumericTextBox = new NumericTextBox({
value: 88,
floatLabelType: 'Auto', placeholder: 'Distance in KM'
//enableRtl: true
});
distanceTextBox.appendTo(inputEle2 );
inputEle2.setAttribute('name', 'km');
}
}
}
The clients are retrieved from my ClientService:
this.clientService.getClients().subscribe((data : any) => {
this.clients = data.client;
})My wish is that the value of distanceTextBox gets populated dynamically depending on which Client the user chooses from the Dropdown List. So for example, 'Bob' is a client in the MongoDB:const relatieSchema = new Schema({
company: {type: String, required: true, unique: false},
distance: {type: Number, required: true},
});If the users clicks on Bob in the Dropdown, the Distance field gets the distance value from this client instantly, instead of the hard-coded 88.Thank you