We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid BatchUpdate Return Status or Error Information

Thread ID:

Created:

Updated:

Platform:

Replies:

121699 Jan 18,2016 04:38 AM UTC Jan 19,2016 10:40 AM UTC ASP.NET MVC 1
loading
Tags: Grid
Jeffrey Stone
Asked On January 18, 2016 04:38 AM UTC

I am using a grid in batch edit mode similar to the following:

ds.URL(@Url.Action("BatchDataSource","AccountSettings")).BatchURL(@Url.Action("BatchUpdate","AccountSettings")).Adaptor(AdaptorType.UrlAdaptor))   
      .EditSettings(edit => { edit.AllowEditing().EditMode(EditMode.Batch); })

Is it possible to return to status messages, most importantly, any error messages after BatchUpdate has been called? Note - I am not using the grid store data in a database; I am using it to execute commands and I would like to inform the user if there were any errors in executing the commands.

Regards, Jeff



Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On January 19, 2016 10:40 AM UTC

Hi Jeff,

Thanks for contacting Syncfusion Support.

Query #1: Is it possible to return to status messages, most importantly, any error messages after BatchUpdate has been called?

From your query, we understand that you would like to display an exception/error message from the server-side. ASP.Net MVC Grid’s ActionFailure event provides you the option to popup a dialog and you can display the exception message/status message, which reports the cause of the error. If any exception is thrown, ActionFailure event will be triggered. Refer to the code example.

@(Html.EJ().Grid<OrdersView>("BatchEditing")

        .Datasource(ds => ds.URL(@Url.Action("DataSource")).BatchURL(@Url.Action("UpdateBatch")).Adaptor(AdaptorType.UrlAdaptor))

         . .  . .

        .Columns(col =>

        {

             . .  .  ..

        })

        .ClientSideEvents(events => { events.ActionFailure("Failure"); })

)


<script>

    function Failure(args) {

        args.error//retreive the error message-check the attached sample for example

    }
</script>

namespace MvcApplication66.Controllers

{

    public class HomeController : Controller

    {

             . . . . . . 

           . . . 

        public ActionResult UpdateBatch(List<EditableOrder> changed, List<EditableOrder> added, List<EditableOrder> deleted)

        {

            if (added != null)

            {

                for (int i = 0; i < added.Count(); i++)

                {

                    if (added[i].OrderID < 1000)

                        throw new InvalidOperationException("OrderID must be above 1000");//Throwing exception for sample purpose                }

                OrderRepository.Add(added);

            }

             . . . . . .  ..

            var data = new NorthwindDataContext().OrdersViews.ToList();

            return Json(data, JsonRequestBehavior.AllowGet);

        }

         . . .  .

    }
}


Query #2: I am not using the grid store data in a database; I am using it to execute commands and I would like to inform the user if there were any errors in executing the commands.

In the above code example, we have updated the dataSource. During the update action, if the condition fails, an exception throws. Likewise, you can throw an exception on executing the commands. If you are facing any difficulty while displaying the error message, please share the commands/code example of Grid and code behind, which would be helpful to analyze the issue and provide the solution as early as possible.

We have prepared a sample that can be downloaded from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/121699/ze/BatchEditing_ActionFailure-84540180

Refer to the Help Document for actionFailure and other events of ejGrid.

http://help.syncfusion.com/js/api/ejgrid#events:actionfailure

http://help.syncfusion.com/js/api/ejgrid#events

Regards,
Seeni Sakthi Kumar S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;