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"
And my front end looks like:
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" }]
}