The dx.aspnet.data.js script is the client-side part. You can install it in one of the following ways.
-
Use npm.
-
Run the following command in the command line:
npm install devextreme-aspnet-data -
Link the
dx.aspnet.data.jsscript on your page:<script src="/node_modules/devextreme-aspnet-data/js/dx.aspnet.data.js"></script>
-
-
Use unpkg.
Link the
dx.aspnet.data.jsscript on your page in the following way:<script src="https://unpkg.com/devextreme-aspnet-data/js/dx.aspnet.data.js"></script>
-
Use bower.
NOTE: Since Bower is deprecated we do not recommend you use this approach.
-
Run the following command in the command line:
bower install devextreme-aspnet-data... or add
devextreme-aspnet-datato the bower.json file'sdependenciessection."dependencies": { ... "devextreme-aspnet-data": "^2" } -
Link the
dx.aspnet.data.jsscript on your page:<script src="/bower_components/devextreme-aspnet-data/js/dx.aspnet.data.js"></script>
-
The client-side API consists of the DevExpress.data.AspNet.createStore method that returns a CustomStore's instance. This instance is configured to access a controller.
When you call the DevExpress.data.AspNet.createStore method, pass an object with the properties described below.
-
cacheRawData- refer toCustomStore.cacheRawData. -
deleteMethod- the HTTP method for delete requests;"DELETE"by default. -
deleteUrl- the URL used to delete data. -
errorHandler- refer toCustomStore.errorHandler. -
insertMethod- the HTTP method for insert requests;"POST"by default. -
insertUrl- the URL used to insert data. -
key- refer toCustomStore.key. -
loadMethod- the HTTP method for load requests;"GET"by default. -
loadMode- refer toCustomStore.loadMode. -
loadParams- additional parameters that should be passed toloadUrl. -
loadUrl- the URL used to load data. -
onAjaxError- a function to be called when an AJAX request fails.onAjaxError: (e: { xhr, error }) => void
The
eobject has the following properties:Property Type Description xhrjqXHRfor jQuery;XMLHttpRequestotherwiseThe request object. errorstringorErrorThe error object. You can assign a custom error message or a JavaScript Errorobject. -
onBeforeSend- a function that customizes the request before it is sent.onBeforeSend: (operation, ajaxSettings) => void | PromiseLike
Parameter Type Description operationstringThe operation to be performed by the request: "load","update","insert", or"delete".ajaxSettingsobjectRequest settings. Refer to jQuery.ajax(). -
onInserted- refer toCustomStore.onInserted. -
onInserting- refer toCustomStore.onInserting. -
onLoaded- refer toCustomStore.onLoaded. -
onLoading- refer toCustomStore.onLoading. -
onModified- refer toCustomStore.onModified. -
onModifying- refer toCustomStore.onModifying. -
onPush- refer toCustomStore.onPush. -
onRemoved- refer toCustomStore.onRemoved. -
onRemoving- refer toCustomStore.onRemoving. -
onUpdated- refer toCustomStore.onUpdated. -
onUpdating- refer toCustomStore.onUpdating. -
updateMethod- the HTTP method for update requests;"PUT"by default. -
updateUrl- the URL used to update data.
Refer to the CustomStore methods and events for a list of available methods and events.
You can find a jQuery example here.
DevExtreme-based ASP.NET Core and DevExtreme ASP.NET MVC 5 controls call the DevExpress.data.AspNet.createStore method internally. To configure its parameters, use the DataSource() method's lambda expression.
@(Html.DevExtreme().DataGrid()
.DataSource(ds => ds.WebApi()
.Controller("NorthwindContext")
.Key("OrderID")
.LoadAction("GetAllOrders")
.InsertAction("InsertOrder")
.UpdateAction("UpdateOrder")
.DeleteAction("RemoveOrder")
)
)