Create a dynamic select control on childgrid #6725
-
I have been able to create an input control on a child grid tool bar as below , how can I create a select dropdown control as well and populate with data from a service. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I would really appreciate any form of assistance |
Beta Was this translation helpful? Give feedback.
-
In your I used existing Language module as an example. private languageSelect: JQuery;
constructor(container: JQuery) {
super(container);
LanguageService.List({}, (response) => {
this.languageSelect = $("<select></select>");
this.languageSelect.append("<option></option>"); //for placeholder
for (const item of response.Entities) {
this.languageSelect.append(format("<option value='{0}'>{1}</option>", item.Id.toString(), item.LanguageName));
}
this.toolbar.element.append(this.languageSelect);
this.languageSelect.select2(<any>{
allowClear: true,
placeholder: 'Please select a Language'
});
});
} You can also use LanguageRow.getLookupAsync().then((lookup) => {
this.languageSelect = $("<select></select>");
this.languageSelect.append("<option></option>");
for (let item of lookup.items) {
this.languageSelect.append(format("<option value='{0}'>{1}</option>", item.Id.toString(), item.LanguageName));
}
this.toolbar.element.append(this.languageSelect);
this.languageSelect.select2(<any>{
allowClear: true,
placeholder: 'Please select a Language'
});
}); To get selected value this.languageSelect.select2('val'); To get selected data (both value and text) this.languageSelect.select2('data'); For other select2 usage, please visit https://select2.github.io/select2/ |
Beta Was this translation helpful? Give feedback.
-
Thank you so much wezmag, it worked perfectly. |
Beta Was this translation helpful? Give feedback.
In your
LineItemListEditor.ts
file, add below code.I used existing Language module as an example.