头图

In Jerry 's tutorial SAP UI5 Application Development Tutorial No. 66 - How to implement the delete function of SAP UI5 table control based on OData V4 , a friend asked a question:

After we select the list line item and click the delete button, an OData delete request will be triggered:

This delete request is triggered by calling the delete method of the BindingContext instance through the 62nd line of code in the ---2a6ca2014330a79e57c99c218759ec66 onDelete function. The input parameter of the delete method is $auto , what does this string mean?

As usual, we can understand the meaning of this parameter by stepping through the Chrome developer tools: Group ID.

You can also find the parameter definitions of the delete method in the official documentation :

This parameter represents the Group ID of the delete request, $auto is the default value.

In the delete implementation of Context.js, the checkGroupId method of the OData model instance will be called to verify the incoming value:

group id is one of the fields used by the SAP UI5 framework to identify and manage OData Batch Request, see the documentation :

The allowed values of group id are $auto , $auto.* and $direct . $auto means the default behavior, that is, the request triggered by calling the API through the OData Model instance is sent to the OData server in batch request mode. $direct means that the request is not sent in batch mode.

Regarding what is the batch sending mode of OData requests, Jerry has already introduced it in detail in my article:

SAP UI5 Application Development Tutorial No. 63 - An in-depth introduction to the implementation of local Mock Server based on OData V4 .

Context will delegate the delete operation to the _delete method of the Binding instance to execute.

In most cases, when we call the delete method of BindingContext, we pass in the default group id $auto .

This is also the reason why the default value is used in the sample code for the implementation of the delete function given in most of the help documents of SAP:

Of course, we can also customize the group id in the application. For specific examples, please refer to this article of the author:

How the SAP UI5 OData V4 model is constructed


注销
1k 声望1.6k 粉丝

invalid