Filter DataSource doesnt Work

3 posts, 1 answers
  1. Shahinez
    Shahinez avatar
    8 posts
    Member since:
    Jul 2017

    Posted 02 Aug 2017 Link to this post

    Hello, 

    I'm a beginner in kendo ui.

    I'm trying to work on a hierarchical grids.

    I'm able to get the parent rows to load fine, however, the child rows are all loaded without considering the filter . 

    Here's the code I'm attempting to run:

    <div class="container" id="example">
        <div id="Div1">
            <div id="grid">
            </div>
            <script>
                $(document).ready(function () {
                    var element = $("#grid").kendoGrid({
                        dataSource:
                        {
                            transport:
                            {
                                read: {  url: "api/Clients", dataType: 'json'},
                            },
                            pageSize: 6,
                            serverPaging: true,
                            serverSorting: true,
                        },
                        height: 600,
                        sortable: true,
                        pageable: true,
                        detailInit: detailInit,
                        
                        columns:
                        [
                            { field: "Code_Client" },
                            { field: "Nom_Client"},
                            { field: "Groupe" },
                            { field: "Cote" },
                            { field: "Marche" }
                        ]
                    });
                });
     
                function detailInit(e) {
                    $("<div />").appendTo(e.detailCell).kendoGrid({
                        dataSource: {
                            transport:
                            {
                               read: {  url: "api/Clients", dataType: 'JSON'}
                            },
                            serverPaging: true,
                            serverSorting: true,
                            serverFiltering: true,
                            pageSize: 10,
                           filter: {field: "Code_Client", operator: "eq",  value: e.data.Code_Client }
                        },
                        scrollable: false,
                        sortable: true,
                        pageable: true,
                        columns: [
                            { field: "Refere" },
                            { field: "Nb_Employe" },
                            { field: "Ca" },
                            { field: "Type" },
                            { field: " Commentaires" },
                            { field: "Sous_Secteur" },
                            { field: "Contact" },
                            { field: "Adresse" },
                            { field: "Téléphone" }
                        ]
                    });
                }
            </script>
        </div>
    </div>

     

    Thank you, 
  2. Answer
    Stefan
    Admin
    Stefan avatar
    3070 posts

    Posted 04 Aug 2017 Link to this post

    Hello Shahinez,

    Thank you for the provided code.

    After inspecting it, the code looks good and should show only the records based on the Code_Client value.

    Please have in mind that this configuration uses serverFiltering, which means that the filtering will be done on the server. If the server is not configurated for filtering, then all data will be shown.

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-serverFiltering

    I can suggest setting server filtering to false, to check if the filter will be applied correctly on the client.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Shahinez
    Shahinez avatar
    8 posts
    Member since:
    Jul 2017

    Posted 04 Aug 2017 Link to this post

    Thank you for your reply !

    I setted the server Filtering to  false, and It works ..

    Best,

Back to Top