- Home
- Forum
- ASP.NET MVC
- Grid ActionFailure error handling
Grid ActionFailure error handling
Hi,
I have the following grid:
@(Html.EJ().Grid<MyViewModel>("mygrid")
.Datasource(ds => ds.Json(Model.MyList.ToList()).RemoveURL("Controller/DeleteOperation").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowDeleting().ShowDeleteConfirmDialog(); })
.AllowPaging()
.AllowSorting()
.AllowFiltering()
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.IsResponsive()
.Columns(col =>
{
col.Field(x => x.model.id).Visible(false).IsPrimaryKey(true).Add();
col.HeaderText("Name").TextAlign(Syncfusion.JavaScript.TextAlign.Left).Field(x => x.model.name).AllowSorting(true).Width(50).Add();
col.HeaderText("Description").TextAlign(Syncfusion.JavaScript.TextAlign.Left).Field(x => x.model.desc).AllowSorting(true).Width(50).Add();
col.HeaderText(" ").IsPrimaryKey(false).Commands(command =>
{
command.Type("edit")
.ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
{
Text = "Edit",
Click = "onEditClick",
Width = "30"
}).Add();
command.Type(UnboundType.Delete)
.ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
{
Text = "Delete",
Width = "40"
}).Add();
}).AllowFiltering(false).Width(20).Add();
}).ClientSideEvents(eve => eve.ActionFailure("FailMessage"))
Then my controller:
[HttpPost]
public ActionResult DeleteOperation(int key)
{
try
{
_service.Delete(key);
}
catch (Exception ex)
{
throw new Exception("Don't do this again");
}
//blah
//blah
//blah
//blah
return Json(mdel, JsonRequestBehavior.AllowGet);
}
and finally my Javascript error handler:
<script type="text/javascript">
function FailMessage(args) {
this.cancelEdit();
var str = args.error.error.responseText;
alert(str);
}
</script>
When I delete the first time the FailMessage is triggered but after dismissing the error message subsequent delete attempts trigger the following error taken from the browser's console:
jquery?v=bXcTrZGqtrcwKAMRnGbw8uWciL3lUOCOt371LT6hr7w1:1 Uncaught TypeError: Cannot read property 'nodeType' of undefined
at attr (jquery?v=bXcTrZGqtrcwKAMRnGbw8uWciL3lUOCOt371LT6hr7w1:1)
at a (jquery?v=bXcTrZGqtrcwKAMRnGbw8uWciL3lUOCOt371LT6hr7w1:1)
at i.fn.init.attr (jquery?v=bXcTrZGqtrcwKAMRnGbw8uWciL3lUOCOt371LT6hr7w1:1)
at Object.selectRows (ej.web.all.min.js:10)
at Object.deleteRow (ej.web.all.min.js:10)
at Object._triggerConfirm (ej.web.all.min.js:10)
at Object.r (jquery?v=bXcTrZGqtrcwKAMRnGbw8uWciL3lUOCOt371LT6hr7w1:1)
at Object._trigger (ej.web.all.min.js:10)
at Object._btnMouseClickEvent (ej.web.all.min.js:10)
at HTMLInputElement.<anonymous> (ej.web.all.min.js:10)
Initially i did not use the "this.cancelEdit();" but i feel i had to because the grid removes the row regardless.
I used the following link as a starting point:
https://www.syncfusion.com/kb/7135/how-to-return-custom-message-from-controller-when-crud-action-fails
Any idea how I can better handle the error messages while preventing the grid from removing the row in case of an error?
Thank you very much.
SIGN IN To post a reply.
5 Replies
PK
Prasanna Kumar Viswanathan
Syncfusion Team
May 11, 2017 11:32 AM UTC
Hi Bradley,
Thanks for contacting Syncfusion support.
We created a sample according to your code example and we can reproduce the mentioned issue in our sample. The mentioned issue is reproduced when we refer the 15.1.0.41 script file in our sample.
We have already created a defect report for this issue and it has been fixed in latest version(15.2.0.40). So, we suggest you to upgrade to the latest version.
Regards,
Prasanna Kumar N.S.V
MB
Martha Bailey
May 11, 2017 12:18 PM UTC
Hi Prasanna,
Thank you for much for the update. Will do.
Best Regards
Best Regards
PK
Prasanna Kumar Viswanathan
Syncfusion Team
May 12, 2017 05:27 AM UTC
Hi Bradley,
You are welcome. Please contact us if you need any further assistance.
Regards,
Prasanna Kumar N.S.V
LL
Luka Lizatovic
May 29, 2017 12:29 PM UTC
Im using latest version (15.2.0.40) and in the same scenario getting following error from browser console:
TypeError: a is undefined jquery-3.1.1.min.js:3:31822
attr http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:31822
S http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:480
attr http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:31667
selectRows http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:1213991
deleteRow http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:1023005
_triggerConfirm http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:1110126
e http://localhost:62310/Scripts/jquery-3.1.1.min.js:2:3653
_trigger http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:12405
_btnMouseClickEvent http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:222788
t.proxy/< http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:26130
dispatch http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:10263
add/q.handle http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:8325
TypeError: a is undefined jquery-3.1.1.min.js:3:31822
attr http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:31822
S http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:480
attr http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:31667
selectRows http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:1213991
deleteRow http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:1023005
_triggerConfirm http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:1110126
e http://localhost:62310/Scripts/jquery-3.1.1.min.js:2:3653
_trigger http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:12405
_btnMouseClickEvent http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:222788
t.proxy/< http://localhost:62310/Scripts/ej/ej.web.all.min.js:10:26130
dispatch http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:10263
add/q.handle http://localhost:62310/Scripts/jquery-3.1.1.min.js:3:8325
Do you have any idea why im getting this error?
Thanks in advance.
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
May 30, 2017 11:56 AM UTC
Hi Luka,
Thanks for contacting syncfusion support.
We are unable to reproduce your reported problem at our end. We have created sample in V15.2.0.40 which can be downloaded from the below location.
We need some additional information to find the cause of the issue. Could you please share us the following details.
1. Share Grid code example(both in client and server side)
2. Please ensure whether the old scripts get referred in your project which might cause the error.
3. Share the screenshot/Video regarding the issue.
4. Replicate the issue in the above sample and revert us back.
5. Share “Layout.cshtml/web.config” file from your sample.
The provided details will helps us to analyze and provide you solution as early as possible.
Regards,
Farveen sulthana T
SIGN IN To post a reply.
- 5 Replies
- 4 Participants
-
MB Martha Bailey
- May 10, 2017 01:31 PM UTC
- May 30, 2017 11:56 AM UTC