JSDO and a nested hierarchical datasource

Posted by Marko Myllymäki on 10-Jun-2016 05:05

Hi,

we are using Kendo and JSDO in our front-end and OE 11.6 Data Object service in the back-end. We would like to consume a service that returns hierarchical data as nested json. I found this example of hiearchical usage:

http://oemobiledemo.progress.com/jsdo/example023.html

In that case, the returned dataset is like this: 

{
"dsCustOrder": {
  "eCustomer": [
  {
    "CustNum": 1,
    "Name": "Urpon frisbee",
    "Address": "276 North Drive"
   }, {...} ],
  "eOrder": [
  {
    "OrderNum": 1,
    "CustNum": 1,
    "OrderDate": "1998-01-26"
   },{...} ]
}}
   

So, the temp-tables eCustomer and eOrder are on the same level. The hierarchy between eCustomer and eOrder is defined in the service.json. This works nicely.

However, in our case we would like to use a nested format. When we add the NESTED keyword in the dataset's relation definition in the business entity, the dataset is returned like this:

{
"dsCustOrder": {
  "eCustomer": [
  {
    "CustNum": 1,
    "Name": "Urpon frisbee",
    "Address": "276 North Drive",   
    "eOrder": [
    {
      "OrderNum": 1,
      "CustNum": 1,
      "OrderDate": "1998-01-26"
    },{...} ]
  }, {...} ]
}}



so every eOrder is nested inside its parenting eCustomer.

Is there a way to consume this kind of response using JSDO? It seems that when using a nested structure, only the top level temp-tables (eCustomer in this case) can be found in the response object so we have no access to eOrder data.

Posted by Marko Myllymäki on 10-Jun-2016 08:17

Hi,

thanks for your response. I had already tried that useRelationsships setting with no effect but now I figured out the reason. I should have mentioned that along with the NESTED option there was also FOREIGN-KEY-HIDDEN set in the dataset relation definition. Removing that FOREIGN-KEY-HIDDEN option solved this issue. So I guess the JSDO could not parse the response properly if the foreign key field was hidden. That makes sense, I should have realized it earlier.

EDIT: And now I realize that the example I had sent had the foreign key, so it was a bad example, not that kind I was having trouble with. Sorry for the confusion.

All Replies

Posted by egarcia on 10-Jun-2016 07:19

Hello,

You should be able to work with multi-table DataSet using NESTED and also without it.

Internally, the JSDO organizes the data into the corresponding structures.

The following post contains information on working with a hierarchical grid

community.progress.com/.../83484

I wonder if you are running into an issue where you need to set the useRelationships property to false to prevent the selection of the records on the child table to use the relationship.

This selection should not apply when using a Kendo UI DataSource because it should use the specified filter which is what you would generally do with Kendo UI.

For version 4.2 of the JSDO, you can set useRelationships to false (example023.html does this):

     jsdoInstance.useRelationships = false;

In a future version, you would not need to set this property to work with a hierarchical grid.

Please let me know if this solves the issue.

I hope this helps.

Posted by Marko Myllymäki on 10-Jun-2016 08:17

Hi,

thanks for your response. I had already tried that useRelationsships setting with no effect but now I figured out the reason. I should have mentioned that along with the NESTED option there was also FOREIGN-KEY-HIDDEN set in the dataset relation definition. Removing that FOREIGN-KEY-HIDDEN option solved this issue. So I guess the JSDO could not parse the response properly if the foreign key field was hidden. That makes sense, I should have realized it earlier.

EDIT: And now I realize that the example I had sent had the foreign key, so it was a bad example, not that kind I was having trouble with. Sorry for the confusion.

This thread is closed