HI Telerik Team,
I am trying to populate grid using datasource. but the grid is not populating
asmx
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetTasks1()
{
JavaScriptSerializer theSerializer =
new
JavaScriptSerializer();
string result =
""
;
List<rt_aw_user_task_details> resultList =
new
List<rt_aw_user_task_details>();
AW_USER_TASK_DETAILS taskDetails =
new
AW_USER_TASK_DETAILS();
taskDetails.Query.Load();
resultList = taskDetails.ToRemotableList();
var
data = resultList.Select(i =>
new
{ i.seq_no, i.task_id, i.category }).ToList();
result =
new
JavaScriptSerializer().Serialize(data);
return
result;
}
aspx page
$(document).ready(
function
() {
var
tasksDataSource =
new
kendo.data.DataSource({
type:
"json"
,
serverFiltering:
true
, serverPaging:
true
, serverSorting:
true
, pageSize: 10,
transport: {
read: {
datatype:
"json"
,
type:
"POST"
,
url:
"Service/MyTasks.asmx/GetTasks"
}
}
});
tasksDataSource.read();
$(
"#grid"
).kendoGrid({
dataSource: tasksDataSource,
height: 400,
groupable:
true
,
sortable:
true
,
pageable: {
refresh:
true
,
pageSizes:
true
,
buttonCount: 5
},
columns: [{
field:
"seq_no"
,
title:
"CATEGORY"
}, {
field:
"task_id"
,
title:
"FREQUENCY"
}, {
field:
"category"
,
title:
"ISANYTIME"
,
}]
});
});
The grid is not loading.......
Is there anything i am missing??
and the service returns the following data
[{
"seq_no"
: 2,
"task_id"
: 96,
"category"
:
"Task"
}, {
"seq_no"
: 3,
"task_id"
: 92,
"category"
:
"Report To Review"
},
{
"seq_no"
: 4,
"task_id"
: 99,
"category"
:
"Meeting"
}, {
"seq_no"
: 5,
"task_id"
: 96,
"category"
:
"Task"
},
{
"seq_no"
: 6,
"task_id"
: 96,
"category"
:
"Task"
}, {
"seq_no"
: 7,
"task_id"
: 93,
"category"
:
"Report To Send"
},
{
"seq_no"
: 8,
"task_id"
: 99,
"category"
:
"Meeting"
}, {
"seq_no"
: 9,
"task_id"
: 96,
"category"
:
"Task"
},
{
"seq_no"
: 10,
"task_id"
: 96,
"category"
:
"Task"
}, {
"seq_no"
: 11,
"task_id"
: 99,
"category"
:
"Meeting"
}]
But it is working when I give the data directly
var
tasksDataSource =
new
kendo.data.DataSource({
data: [
{
"seq_no"
: 2,
"task_id"
: 96,
"category"
:
"Task"
}, {
"seq_no"
: 3,
"task_id"
: 92,
"category"
:
"Report To Review"
},
{
"seq_no"
: 4,
"task_id"
: 99,
"category"
:
"Meeting"
}, {
"seq_no"
: 5,
"task_id"
: 96,
"category"
:
"Task"
},
{
"seq_no"
: 6,
"task_id"
: 96,
"category"
:
"Task"
}, {
"seq_no"
: 7,
"task_id"
: 93,
"category"
:
"Report To Send"
},
{
"seq_no"
: 8,
"task_id"
: 99,
"category"
:
"Meeting"
}, {
"seq_no"
: 9,
"task_id"
: 96,
"category"
:
"Task"
},
{
"seq_no"
: 10,
"task_id"
: 96,
"category"
:
"Task"
}, {
"seq_no"
: 11,
"task_id"
: 99,
"category"
:
"Meeting"
}]
});
tasksDataSource.read();