Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Master-Details example #292

Open
darianferrer opened this issue Jun 15, 2017 · 1 comment
Open

Master-Details example #292

darianferrer opened this issue Jun 15, 2017 · 1 comment

Comments

@darianferrer
Copy link

Hi,

I've a view where there is a form (category entity) and a list with inline edition (service entity). In my model, I define that Category has a collection of Service and also Service has a navigation property to Category. What I'm trying is to add the new category with its collection of service. The odata config is set with enableDeepSave = false and withReferenceMethods = true.

If I create a new category with one service, the batch request looks like this:

POST http://localhost:20300/odata/ProductServiceTypes HTTP/1.1
Content-ID: 1
Accept: application/json;q=0.9, /;q=0.1
OData-Version: 4.0
Content-Type: application/json
OData-MaxVersion: 4.0

{"id":0,"createdById":0,"modifiedById":0,"dynamicProperties":{"displayName":{"en":"T"}}}
--changeset_b91b-bbbe-e01c
Content-Type: application/http
Content-Transfer-Encoding: binary

POST http://localhost:20300/odata/ProductCategories HTTP/1.1
Content-ID: 2
Accept: application/json;q=0.9, /;q=0.1
OData-Version: 4.0
Content-Type: application/json
OData-MaxVersion: 4.0

{"id":0,"productType":"General","canHaveSupplementsOrDiscounts":true,"canHaveContracts":true,"createdById":0,"modifiedById":0,"dynamicProperties":{"displayName":{"en":"T"}}}
--changeset_b91b-bbbe-e01c
Content-Type: application/http
Content-Transfer-Encoding: binary

POST $2/services/$ref HTTP/1.1
If-Match: *
Content-ID: 3
Accept: application/json;q=0.9, /;q=0.1
OData-Version: 4.0
Content-Type: application/json
OData-MaxVersion: 4.0

{}

You can see one post for each entity and the last one would be the association between the two entities, but its body is empty. Debugging the oDataProvider.js, it seems that with a collection it cannot set the @odata.id property. Is there a way to solve this?

@darianferrer
Copy link
Author

I think the fix is quite simple: in oDataProvider.js, line 742, value is an array, inside are the items with __convertedRefence, adding something like and a little refactoring would do the trick:

if(Array.isArray(value)){ for(var i = 0; i < value.length; i++){ // same process as line 746 } }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant