Hi!
i have the following code:
Razor@(Html.DevExtreme().DataGrid<Company>()
.ID("datagrid-companies")
.DataSource(ds =>
{
return ds.Mvc().Controller("Companies")
.LoadAction(Globals.EntityControllerLoadAction)
.UpdateAction(Globals.EntityControllerUpdateAction)
.InsertAction(Globals.EntityControllerInsertAction)
.DeleteAction(Globals.EntityControllerDeleteAction)
.Key("Id");
})
.OnInitNewRow(
@<text>
function onInitNewRow(options) {
options.data.ManualRequestsForCollections = true;
}
</text>
)
.Editing(editing =>
{
editing.Mode(GridEditMode.Popup);
editing.AllowAdding(true);
editing.AllowUpdating(true);
editing.AllowDeleting(true);
editing.UseIcons(true);
editing.Popup(p =>
{
p.Title("Compañia")
.ShowTitle(true);
});
editing.Form(f =>
{
f.ShowValidationSummary(true);
f.Items(items =>
{
items.AddGroup().ColCount(2).ColSpan(2).Items(groupItems =>
{
groupItems.AddSimpleFor(m => m.ManualRequestsForCollections).ColSpan(2).Editor(e => e.CheckBox().OnValueChanged(@"function(args) { onManualRequestsForCollectionsValueChanged(args, setValue); }"));
});
});
});
})
.Columns(columns => {
columns.AddFor(m => m.ManualRequestsForCollections).CellTemplate(@<text>
[% if(data.ManualRequestsForCollections == true) { %]
<span class="badge badge-success">Sí</span>
[% } else { %]
<span class="badge badge-danger">No</span>
[% } %]
</text>).Width(Globals.DataGridMediumColumnWidth);
})
)
<script>
function onManualRequestsForCollectionsValueChanged(args, setValueMethod) {
setValueMethod(args.value);
var myDialog = DevExpress.ui.dialog.custom({
showTitle: false,
messageHtml: "¡Recuerde que este cambio solo afecta a los nuevos envases y que los usuarios de las PDA's deben volver a inicar sesión para que los cambios tengan efecto!",
buttons: [
{
text: "Aceptar",
onClick: function (b) {
return { buttonText: b.component.option("text") }
}
}]
});
myDialog.show();
}
</script>
It seems that if I override the OnValueChanged function of the Checkbox, and the user only edit the value of the checkbox, the update function of the controller never executes. It is as if there are no changes for the specific row that has been modified.
If the code is empty, the onManualRequestsForCollectionsValueChanged function still does not work, so the custom dialog has nothing to do with it, it is simply due to the fact of overriding the event
Currently, from what I have read in your forums I have to use the setValue function.
The problem is that I can't do it. I have the error of SetValue is undefined. Can you help me and tell me what is missing from my code?
Best Regards.