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

Filter DataSource doesnt Work

2 Answers 698 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shahinez
Top achievements
Rank 1
Shahinez asked on 02 Aug 2017, 01:13 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 04 Aug 2017, 08:09 AM
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.
0
Shahinez
Top achievements
Rank 1
answered on 04 Aug 2017, 09:55 AM

Thank you for your reply !

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

Best,

Tags
Grid
Asked by
Shahinez
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Shahinez
Top achievements
Rank 1
Share this question
or