or
$(
'#btnSearch'
).on(
"click"
,
function
(e) {
refreshGrid();
return
false
;
});
function
refreshGrid() {
$filter =
new
Array();
$filter.push({ field:
"StudentID"
, operator:
"contains"
, value: $(
'#txtStudentID'
).val() });
if
($(
'#AwardType'
).val()) {
$filter.push({ field:
"Award.AwardTypeID"
, operator:
"eq"
, value: $(
'#AwardType'
).val() });
}
var
grid = $(
"#Grid"
).data(
"kendoGrid"
);
grid.dataSource.filter($filter);
grid.dataSource.read();
}
public ActionResult ApplicationSearch_Read([DataSourceRequest]DataSourceRequest request)
{
var
applications = context.Applications.Include(
"ApplicationDetails"
).OrderByDescending(p => p.SubmittedDate).ToList();
var
data = applications.Select(x =>
new
{
ApplicationID = x.ApplicationID,
SubmittedDate = x.SubmittedDate,
FirstName = x.FirstName,
LastName = x.LastName,
StudentID = x.StudentID,
IsApplicationSubmitted = x.IsApplicationSubmitted,
Award = x.ApplicationDetails.Select(y =>
new
{
AwardID = y.AwardDetail.AwardID,
AwardName = y.AwardDetail.Award.AwardName,
AwardTypeID = y.AwardDetail.Award.AwardTypeID
})
});
return
Json(data.ToDataSourceResult(request));
}
All... I have to change the Grid Layout on an user selection. So the grid will have different column layout and different datasource set for each User selection..
So I did the obvious chose of a Kendo Newbe ... I destroyed the previously created Kendo grid, cleared the grid inner html and recreated the kendo grid using the new column values
Everything works fine.. but after the second selection (first selection is when the kendogrid is first created) ... the grouping wont work ..
any lime light on this issue is appriciated...
Here is the code snippit..
<div id="grid" style="height: 380px"></div>
01.
var
contactGroupsDataSource =
new
kendo.data.DataSource({
02.
transport: {
03.
read: {
04.
url:
"api/contactgroups"
05.
}
06.
}
07.
});
08.
09.
$(
'#contactGroupsList'
).kendoListView({
10.
dataSource: contactGroupsDataSource,
11.
template:
"<li class='contactGroupListItem' data-number='${Number}'>${Number} ${Name} (<span data-bind="
text: cgcount[1]
"></span>) </li>"
12.
});
13.
14.
viewModel = kendo.observable({
15.
contactsDataSource:
new
kendo.data.DataSource({
16.
transport: {
17.
read: {
18.
url:
"api/contacts"
19.
}
20.
},
21.
schema: {
22.
model: {
23.
id:
"Id"
,
24.
fields: {
25.
id: { type:
"string"
},
26.
FirstName: { type:
"string"
},
27.
LastName: { type:
"string"
},
28.
ContactGroupNumber: { type:
"integer"
}
29.
}
30.
}
31.
},
32.
change:
function
(e) {
33.
var
data =
this
.data();
34.
35.
for
(
var
i = 0; i < data.length; i++) {
36.
var
cg = data[i][
"ContactGroupNumber"
];
37.
viewModel.cgcount.splice([cg - 1], 1, viewModel.cgcount[cg - 1] + 1);
38.
}
39.
40.
for
(
var
i = 0; i < 7; i++) {
41.
console.log(i + 1 +
': '
+ viewModel.cgcount[i]);
42.
}
43.
}
44.
}),
45.
cgcount:
new
kendo.data.ObservableArray([0, 0, 0, 0, 0, 0, 0])
46.
});
47.
48.
kendo.bind($(
"#contactsGroupContainer"
), viewModel);
49.
50.
contactsListView = $(
'#contactsList'
).kendoGrid({
51.
dataSource: viewModel.contactsDataSource,
52.
sortable:
true
,
53.
rowTemplate: kendo.template($(
"#rowTemplate"
).html())
54.
});
public
class
User
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
}
@(Html.Kendo().MultiSelectFor(model => model.Members)
.DataValueField(
"Id"
)
.DataTextField(
"Name"
)
.Placeholder(
"Type user's name..."
)
.DataSource(source =>
{
source.Read(read =>
{
read.Action(
"MemberRead"
,
"Group"
);
});
})
)Id:0
Name:Test
Description:Test
Members.Id:1
Members.Name:Jan
Members:[object Object]