I created a EJS grid and i defined my columns like it is mentioned below ,
i tried to add an event listener to the field "mar_intitule_marche " which will be triggered everytime the value of the field changes . but after trying many alternatives nothing worked , any suggestions please ,
thanks in advance
Hi yh bil,
Query: Trigger an action when the value of the field changes
From the information you provided, we understand that you are attempting to perform an action when the value of the "mar_intitule_marche" field changes. This field is a DropdownEdit type in Dialog Edit mode.
The dropdown generated in the "mar_intitule_marche" field is a Syncfusion Dropdown component. By default, the Syncfusion Dropdown component includes a change event that is triggered when an item in the dropdown is selected or when the model value is changed by the user.
We have created a custom solution sample based on your update. Our suggestion is to set the change event of the Syncfusion Dropdown component inside the actionComplete event of the Grid. This event will be triggered after the dialog edit mode is created.
For more information, please refer to the below code example, API Documentation, Screenshot, and the attached sample.
|
[Views\Home\Index.cshtml]
@(Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource.ToArray()).ActionComplete("actionComplete") .Columns(col => { col.Field("CustomerName.FirstName").HeaderText("Customer Name").Add(); col.Field("ShipName").HeaderText("Ship Name").EditType("dropdownedit").Add(); col.Field("ShipCountry").HeaderText("Ship Country").EditType("dropdownedit").Add(); }).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Render())
<script> var fieldName = "ShipName"; function actionComplete(args) { if ((args.requestType === 'beginEdit' || args.requestType === 'add')) { var dialog = args.dialog; dialog.element.querySelector('#Grid' + fieldName).ej2_instances[0].change = () => { console.log("changed"); } } } </script> |
change API: https://ej2.syncfusion.com/documentation/api/drop-down-list#change
actionComplete API: https://ej2.syncfusion.com/documentation/api/grid#actioncomplete
Screenshot:
Please feel free to contact us if you require any further assistance. We are always available and eager to help you in any way we can.
Regards,
Hemanth Kumar S
Thank you so much , i can finally use the trigger an action everytime the selected value changes , i really really appreciate your answer
Hi yh bil,
Thank you for your message. We are pleased to hear that you found our suggested approach helpful. If you feel that it adequately addresses your concern, please consider accepting it as the solution. Doing so will make it easier for other members to find the solution quickly.
Regards,
Hemanth Kumar S