This is a migrated thread and some comments may be shown as answers.

Hierarchical Data Source Expand Filter

5 Answers 130 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Johann
Top achievements
Rank 1
Johann asked on 03 Sep 2015, 03:02 PM

Hi,

Question 1
I'm having some difficulty in applying a filter on an hierarchical data source. It seems to have to do with the difference between getByID and getByFilter as indicated in the following documentation: http://docs.telerik.com/platform/backend-services/javascript/data/relations/relations-defining
My code:

01.var expandExpr = {
02.            "Accounts": {
03.                "TargetTypeName": "Account",
04.                "ReturnAs": "Accounts",
05.               // "Filter": { field: "MainAccount", operator: "eq", value: true },
06.               // "Filter": { "MainAccount": { "eq": true } }
07.            }
08.        };
09.  
10.  
11.        var overviewDataSource = new kendo.data.HierarchicalDataSource({
12.            type: 'everlive',
13.            transport: {
14.                // Required by Backend Services
15.                typeName: 'User',
16.                read: {
17.                    contentType: "application/json",
18.                    headers: {
19.                        "X-Everlive-Expand": JSON.stringify(expandExpr)
20.                    }
21.                }
22.            },
23.  
24.  
25.            schema: {
26.                model: userModel,
27.                hasChildren: function (item) {
28.                    return item.?Accounts && item.Accounts.length > 0;
29.                },
30.                children: "Accounts"
31.            },
32.  
33.            change: function (e) {
34.  
35.                if (e.items && e.items.length > 0) {
36.                    $('#no-overview-span').hide();
37.                } else {
38.                    $('#no-overview-span').show();
39.                }
40.            },
41.            serverFiltering: true,
42.            filter: { field: "Name", operator: "eq", value: "Savings" },
43.            sort: { field: 'Name', dir: 'asc' }
44.        });

 

If either of the filters within expandExpr (lines 5 and 6) is uncommented error 618 is returned by the request.
Can this be overcome, please indicate how?

 

Question 2
I the sample above there are ?Users with multiple Accounts linked to each User. ?And an Account have multiple Transactions. How will I be able expand and filter the Transactions linked to the Account.

Please assist.

Thanks,
Johann

 

 

5 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 07 Sep 2015, 11:28 AM
Hi Johann,

To answer your first question - using a filter in the expand expression is not supported for GetByFilter scenarios, but only when you are getting items by id (GetById). This is why the requests are failing. To accomplish what you are trying to do you need to employ "lazy loading" as shown in the documentation.

For example:

      var accountsExpandNode = {
        relation: "AccountIds",
        filter: {
            MainAccount: true
        }
    };
 
    var tsactionsExpandNote = {
        relation: "TransactionIds",
        filter: {}
    };
 
    var hierarchicalDS = Everlive.createHierarchicalDataSource({
        "typeName": "CustomUser",
        "expand": [accountsExpandNode, tsactionsExpandNote]
    });

The following hierarchical datasource will read the CustomUser type. After that it will get all the relations to the Account type by filter where the MainAccount is equal to true. Finally on the next request it will get all the related Transactions to the expanded account or by the specified filter.

Please note that in the example we are using a CustomUser type because at the current stage expanding deeper than one level for the Users type is not supported.

For more details on lazy loading please check the hierarchical datasource documentation: http://docs.telerik.com/platform/backend-services/javascript/integrations/kendoui/kendoui-uihierarchical-data-source

Let me know if you have questions.

Regards,
Vasil
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Johann
Top achievements
Rank 1
answered on 08 Sep 2015, 01:14 PM

Hi Vasil,

Thank you for responding to my problem.

I get what you are saying but how do I use the CustomUser type? Do I need to define a schema?

Do yo perhaps have a working example that I can look at?

Thanks,
Johann

0
Anton Dobrev
Telerik team
answered on 10 Sep 2015, 01:06 PM
Hi Johann,

The example my colleague provided was in regard to show how the nested expanding works. Yet, I am afraid that the CustomUser type was used to exemplify a type that does not fall under the limitations for expanding the hierarchy starting from Users. The functionality provided by the integrated Users type cannot be provided by other custom content type.

May I ask about the exact workflow you need to drill down the hierarchy data for the user, perhaps there might be a better approach?

At the moment we consider to address the limitation you encountered, however, we cannot commit to a time-frame or to the actual implementation.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Johann
Top achievements
Rank 1
answered on 10 Sep 2015, 01:14 PM

Hi Anton,

Once again I appreciate the response.

Will it be preferred by the support team if I open a support ticket?

If not let me know and I'll post my answer to your question here but as this is public I'd prefer another way.

Regards,

Johann

0
Vasil
Telerik team
answered on 11 Sep 2015, 02:23 PM
Hi Johann,

You should be able to ask your questions in the forum as we have noticed that you currently do not have support tickets included in your subscription. It is not necessary to provide detailed explanation or sensitive details regarding your implementation.

To answer your question - if you want to use the system Users type what you could do is skip using the hierarchical datasource until the limitation is removed. Instead use the Everlive SDK directly by making the necessary requests and binding them manually. Here you can see how to bind your data to a Kendo View: https://github.com/PlatformSupport/screenbuilder-kendo/blob/master/Sample%20App%20Hybrid/home/index.js

Once you get the response you can provide the option to navigate to another view which would receive the parent's Id as a parameter, make another call to the relevant content type and bind the response to the new view.

In addition, I'd suggest that you take a look into this excellent blog post on the same matter. Note the section that explains how to pass the parameters in the query string since this also seems applicable to your use case.

Another helpful resource on binding data to views in Kendo can be found here: http://blog.falafel.com/view-context-for-kendo-ui-mobile-and-mvvm/

​For more information on implementing this you can view the official Kendo documentation.

You can find the API reference for the kendo.ui.mobile.View class at this link.

Let me know if this helps.

Regards,
Vasil
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
General Discussion
Asked by
Johann
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Johann
Top achievements
Rank 1
Anton Dobrev
Telerik team
Share this question
or