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

Remote Datasource filtering

1 Answer 88 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
manpreet
Top achievements
Rank 1
manpreet asked on 13 Oct 2014, 11:52 AM
Hi there,

I have a tree view control on my view and I am binding to a json data source in controller code.

       <div kendo-tree-view="tvc.tree"
            k-data-source="tvc.treeData"
            k-options="tvc.treeOptions">
        </div>


Controller Code :

$scope.tvc = {};

        $scope.tvc.treeData = new kendo.data.HierarchicalDataSource({
            transport: {
                read: {
                    url: options.api.base_url + "/GeoCodeData",
                    dataType: "json"
                }
            },
            schema: {
                model: {
                    id: "GeoCode",
                    hasChildren: function (e) {
                        return true;
                    }
                }
            }
        });

        $scope.tvc.treeOptions = {
            checkboxes: {
                checkChildren: true
            },
            dataTextField: "GeoCode"
        };


Everything works fine when it loads the root node. On subsequent expansion of nodes, it fetches data again by querying datasource. The only parameter passed is "GeoCode" which is defined in schema model.

My requirement is to pass additional filters. The model, with which tree view is binding contains 3 properties. I need to pass like this.

http://localhost:4416/api/GeoCodeData?GeoCode=US&GeoLvl=1

Currently, it is fetching like this :

http://localhost:4416/api/GeoCodeData?GeoCode=US

Any pointers will be appreciated.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 15 Oct 2014, 08:48 AM
Hello Manpreet,

You can pass additional data along with the request by setting the transport.read.data field. If you need to compute the URL each time, set the transport.read.url field as a function. For maximum flexibility, you can define tranport.read as a function and make the AJAX request manually -- see the custom binding help topic.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
manpreet
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or