Auto-focusing a control on selection
I have a table with rows of Syncfusion controls for taking customer order. One of the controls is MultiColumnComboBox for selecting products
My requirement is to run some logic and then move focus to a numerictextbox on the same row once selection is made. I developed JavaScript helper for moving focus and I invoke this method in OnValueSelect event handler,
Everything works fine except the focus. The problem is that once selection made the numerictextbox receives focus and immediately loses it. I have also tried invoking the focus setting logic in PopupClosed event handler but no success.
Thanks for usual assistance
Regards.
Paul Aziz
Hi Paul,
We have validated your requirement to set focus on the NumericTextBox when an event is triggered from the MultiColumnComboBox.
This can be achieved by using either the PopupClosed or ValueChange event of the MultiColumnComboBox component. Within the event handler, you can use a Task.Delay to ensure the focus is set after the popup closes or the value changes. Then, call the FocusAsync method to programmatically set focus to the NumericTextBox.
Please refer to the code snippet and the attached sample file for implementation details.
|
<table> <tr> <td> <SfMultiColumnComboBox TItem="Games" @ref="@multicolumnObj" TValue="string" DataSource="LocalData" ValueField="Game" Placeholder="Select a game" TextField="Game" PopupClosed="OnChange"> </SfMultiColumnComboBox> </td> <td> <SfNumericTextBox @ref="@NumericTextBoxObj" TValue="int?" Value="100"></SfNumericTextBox> </td> </tr> </table> …. public async void OnChange() { await Task.Delay(100); await NumericTextBoxObj.FocusAsync(); } |
Output screenshot:
Please let us know if you need any further assistance or clarification.
Regards,
YuvanShankar A
Attachment: Home_f5db0b99.zip
Hello YuvanShankar A,
Thanks so much for your assistance.
Best reagrds,
Paul Aiziz
Hi Paul,
Glad to know that the provided solution helped, please get back to us for assistance in the future.
Regards,
Shereen