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

ServerSorting from database

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ak12345
Top achievements
Rank 1
ak12345 asked on 19 May 2014, 02:09 PM
Hi, I have an application which has a huge amount of data to be loaded into Kendo grid. I am using web forms(aspx). Since I need to download some thousands of rows into grid, I am trying to load the data from database by giving the page size.

I want the sort to be done for all the rows, but for my code, sorting is done only for those 2000 rows in the current view.

Can anyone please let  me know which is the good way to do serversorting and serverpaging with lot of data in the database that should be loaded into the kendo grid.

Thanks in advance!

Here is my code:
 Dim get_data As String = "select fname, lname, address, phnum from contacts limit  " & limit & ", 2000"

'limit here is taking the page numberr
          Dim JSON_result As String = "["
          'get the data from DB and make it a JSON string
 
          Dim connection1 As New MySqlConnection(constr)
          connection1.Open()
          Dim get_Command As New MySqlCommand(get_data, connection1)
          Dim reader As MySqlDataReader = get_Command.ExecuteReader()
          While reader.Read()
 
              Dim FirstName As String = reader("fname").ToString()
              Dim LastName As String = reader("lname").ToString()
              Dim address As String = reader("address").ToString()
              Dim phnum As String = reader("phnum").ToString()
             
 
              JSON_result += "{""First Name"":""" & FirstName & """, ""Last Name"":""" & LastName& """, ""Address"":""" & address & """, ""contact"":""" & phnum& """},"
          End While
          JSON_result = JSON_result.Remove(JSON_result.Length - 1)
          JSON_result += "]"

And my front end looks like:

var grid = $("#gridAllRuns").kendoGrid({
                       dataSource: {
                           type: "json",
                           transport: {
                               read: url_load
                           },
                           schema: {                               
                               total: function (response) {
                                   return 43658;
                               }
                           },
                           serverPaging: true,
                            
                           pageSize: 2000
                       },
                       dataBound: onDataBound,
                       height: $(document).height() - 250,
                       groupable: true,
                       sortable:true,
                       reorderable: true,
                       //selectable: "multiple",
                       resizable: true,
                       pageable: true,
                      
                          filterable: {
                           extra: false,
 
                           operators: {
                               string: {
                                   eq: "equal to",
                                   startswith: "starts with",
                                   neq: "not equal to"
                               }
                           }
                       },
                       toolbar: kendo.template($("#template").html()),
                       columns: [
                           { title: "First name", field: "First Name"},
                           { title: "Last name", field: "Last Name" },
                           { title: "Address", field: "Address" }]
            }



1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 May 2014, 01:23 PM
Hi,

I would suggest to check the example projects from our ASP.NET GitHub repository on this page. They demonstrate how to perform the paging, sorting and filtering on the server by using the Kendo.DynamicLinq library.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
ak12345
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or