Remote Datasource filtering

2 posts, 1 answers
  1. manpreet
    manpreet avatar
    3 posts
    Member since:
    Sep 2014

    Posted 13 Oct 2014 Link to this post

    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.
  2. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 15 Oct 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top