2017-07-09 3 views
0

Ich benutze telerik kendo ui grid.telerik kendo ui datenanforderung sort field immer null

<script> 
     $(document).ready(function() { 
      $("#grid").kendoGrid({ 
       dataSource: { 
        type: "POST", 
        prefix: "", 
        dataType: "json", 
        serverFiltering: true, 
        EnableCustomBinding:true, 
        transport: { 
         read: "http://localhost:51618/Home/Customers_Read" 
        }, 
        pageSize: 20, 
        serverPaging: true, 
        serverFiltering: true, 
        serverSorting: true, 
        contentType: "application/json; charset=utf-8" 
       }, 
       height: 550, 
       groupable: true, 
       filterable:true, 
       sortable: true, 
       pageable: { 
        refresh: true, 
        pageSizes: true, 
        buttonCount: 5 
       }, 
       columns: [{ 
        template: "<div class='customer-photo'" + 
            "style='background-image: url(../content/web/Customers/#:data.CustomerID#.jpg);'></div>" + 
           "<div class='customer-name'>#: ContactName #</div>", 
        field: "ContactName", 
        title: "Contact Name", 
        width: 240 
       }, { 
        field: "ContactTitle", 
        title: "Contact Title" 
       }, { 
        field: "CompanyName", 
        title: "Company Name" 
       }, { 
        field: "Country", 
        width: 150 
       }] 
      }); 
     }); 
    </script> 

mein Controller ist:

public ActionResult Customers_Read([DataSourceRequest] DataSourceRequest request) 
     { 
// do something 
} 

die Anfrage senden Formular gird ist:

http://localhost:51618/Home/Customers_Read?take=20&skip=0&page=1&pageSize=20&sort%5B0%5D%5Bfield%5D=ContactName&sort%5B0%5D%5Bdir%5D=asc 

aber Datarequest Sortierfeld ist immer null.

Antwort

0

, wenn Sie es so zu revidieren - sollte es funktionieren (es für mich getan hat):

$(document).ready(function() { 
     var ds = new kendo.data.DataSource({ 
      type: "aspnetmvc-ajax",  
        transport: { 
         read: "http://localhost:51618/Home/Customers_Read", 
        dataType: "json", 
        type: "POST" 
        }, 
        pageSize: 20, 
        serverPaging: true, 
        serverFiltering: true, 
        serverSorting: true, 
       }); 

      $("#grid").kendoGrid({ 
       dataSource: ds, 
       height: 550, 
       groupable: true, 
       filterable:true, 
       sortable: true, 
       pageable: { 
        refresh: true, 
        pageSizes: true, 
        buttonCount: 5 
       }, 
       columns: [{ 
        template: "<div class='customer-photo'" + 
            "style='background-image: url(../content/web/Customers/#:data.CustomerID#.jpg);'></div>" + 
           "<div class='customer-name'>#: ContactName #</div>", 
        field: "ContactName", 
        title: "Contact Name", 
        width: 240 
       }, { 
        field: "ContactTitle", 
        title: "Contact Title" 
       }, { 
        field: "CompanyName", 
        title: "Company Name" 
       }, { 
        field: "Country", 
        width: 150 
       }] 
      }); 
     }); 
Verwandte Themen