Skip to main content

MVCxClientGridView.BeginCallback Event

Occurs when a callback for server-side processing is initiated.

#Declaration

TypeScript
BeginCallback: ASPxClientEvent<MVCxClientBeginCallbackEventHandler<MVCxClientGridView>>

#Event Data

The BeginCallback event's data class is MVCxClientBeginCallbackEventArgs. The following properties provide information specific to this event:

Property Description
command Gets a command name that identifies which client action initiated a callback. Inherited from ASPxClientBeginCallbackEventArgs.
customArgs Gets an object containing specific information (if any, as name/value pairs) that should be passed as a request parameter from the client to the server side for further processing.

#Remarks

The BeginCallback and ASPxClientGridView.EndCallback events can be used to perform specific client-side actions (for example, to display and hide an explanatory text or picture) while a callback is being processed on the server side.

By handling the BeginCallback event, you can pass any required information from the client to the server via the MVCxClientBeginCallbackEventArgs.customArgs property.

#Example

The example covers the following topics:

  • the GridView extension is bound to a DataSet that is filtered by external editors;
  • when a callback is performed, the grid’s ASPxClientGridView.BeginCallback event is handled. In the MVC GridView extension, it is possible to transmit client-side values as callback arguments to a Controller’s Action, returning a Partial View;
  • jQuery asynchronous requests are not able to serialize the Date, and thus the serialization should be performed manually;
  • a DateTime object is created from a serialized string using the DateTime.ParseExact method;
  • custom resources (scripts and CSS files) are compressed using the HTTP Handler.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Example.Models;
using System.Web.Script.Serialization;
using System.Globalization;

namespace Example.Controllers {
    public class HomeController : Controller {
        public ActionResult Index() {
            //default data
            OrdersModel model = new OrdersModel {
                StartDate = new DateTime(1996, 8, 1),
                EndDate = new DateTime(1996, 8, 30)
            };

            return View(model);
        }

        [HttpPost]
        public ActionResult GridViewPartial() {
            OrdersModel model = new OrdersModel {
                StartDate = DateTime.ParseExact(Request.Params["StartDate"], "d|M|yyyy", CultureInfo.InvariantCulture),
                EndDate = DateTime.ParseExact(Request.Params["EndDate"], "d|M|yyyy", CultureInfo.InvariantCulture)
            };

            return PartialView("_GridView", model.Data);
        }
    }
}
See Also