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

Sorting problem

0 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roberto
Top achievements
Rank 1
Roberto asked on 19 Mar 2012, 05:30 PM
Hi,

i create this to get grid info from mysql database:

<div id="grid"></div>
 <script>
             
                 
                $(document).ready(function() {
                    $("#grid").kendoGrid({
                        dataSource: {
                                                 
                            transport: {
                                read: {
                                    url: "page.php",
                                    type: "post",
                                    dataType: "json"
                                }
                            },
                            schema: {
                                 
                                data: "data",
                                total: "pageSize"
                                 
                            },
                            pageSize: 200,
                            serverPaging: true,
                    serverSorting: true
                        },
                        
                         
                         
                        height: 450,
                        scrollable: true,
                        groupable: true,
                        sortable: true,
                        filterable: true,
                        pageable: true,
            selectable: "multiple row",
                         
                        columns: [
                            {
                                field: "sel",
                                template: "<input type=\'checkbox\' id=\'select\' name=\'sel\' value=#=ARTICLE_ID#  />",
                                filterable: false,
                                sortable: false,
                                groupable: false,
                                width: 50
                            },
                            "CODE",
                            
                            {
                                field: "CATEGORY_NAME",
                                title: "CATEGORY"
                                 
                            }
                            ,
                            "ARTICLE_NAME",
                                 
                            {
                                field: "edit",
                                template: "<a class=\'link_page\' href=\'/gestionale/factory/article/edit/id/#=ARTICLE_ID#\'>Edit</a>",
                                filterable: false,
                                sortable: false,
                                groupable: false,
                                width: 50
                            },
                        ]
                    });
                });
            </script>

my page.php

i do a query with an inner join

select a.NAME as ARTICLE_NAME,a.CODE,c.NAME as CATEGORY_NAME from T_ARTICLE as a inner join T_CATEGORY as c on a.CATEGORY_ID = c.ID

i do serverSorting because the table have more rows (300.000). When i click on TH CATEGORY_NAME the script run a ajax call to page.php and passes through POST the sort array  with the FIELD CATEGORY_NAME, but the query is wrong because in ORDER clause i don't insert CATEGORY_NAME, i would insert c.NAME. 
Is it possible to define the name of the fields that i will use in the sort and filter?

Thanks 



 

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Roberto
Top achievements
Rank 1
Share this question
or