Hi I am looking into building products using KendoUI MVC as potential tool in future. I have been messing around in the trial and for the most part it is fairly straight forward. I have run into one issue as follows.
I have a controller for a Contact. It has one view in particular, ViewDetails
It takes a list of contacts passed in as an array, assigns it to the viewdata and returns the View. This view has a KendoUI Grid in it and the code is as follows
The problem I am having occurs on line 35. When I try to assign the Data for "contactId", in the resulting javascript it appears that the only data is System.Int64[] like it called ToString on the data instead of taking the array and passing its contents as multiple named parameters.
The select function of course fails as there is not a proper contactId parameter passed, it is as follows for reference
Thanks for your assistance. This is one of the few snags I have seen reviewing the product, I hope to get it resolved so I can continue my evaluation in a timely fashion!
I have a controller for a Contact. It has one view in particular, ViewDetails
1.
public
ActionResult ViewDetails(
long
[] contactId)
2.
{
3.
ViewData[
"contactId"
] = contactId;
4.
return
View();
5.
}
01.
@{
02.
ViewBag.Title = "ViewDetails";
03.
Layout = "~/Views/Shared/_Layout.cshtml";
04.
}
05.
06.
<
h2
>ViewDetails</
h2
>
07.
08.
09.
@(
10.
11.
@Html.Kendo().Grid<
DetailGridViewModel
>()
12.
.Name("Grid")
13.
.Columns(columns =>
14.
{
15.
columns.Bound(p => p.ContactId).Hidden();
16.
columns.Bound(p => p.ContactNumber);
17.
columns.Bound(p => p.ContactName);
18.
columns.Bound(p => p.Date).Width(130).Format("{0:d}");
19.
columns.Bound(p => p.ContactStatus);
20.
columns.Bound(p => p.Type);
21.
columns.Command(command =>
22.
{
23.
24.
}).Width(200);
25.
26.
})
27.
28.
29.
.Sortable( )
30.
.Resizable(resize => resize.Columns(true))
31.
.Filterable()
32.
.DataSource(dataBinding =>
33.
dataBinding.Ajax().Aggregates(agg => { agg.Add(com => com.Value).Sum();
34.
agg.Add(p => p.ContactCost).Sum();
35.
}).Read(read => read.Action("_SelectDetails", "Contacts").Data(obj => new {contactId = ViewData["contactId"]}))))
36.
The select function of course fails as there is not a proper contactId parameter passed, it is as follows for reference
01.
public
ActionResult _SelectDetails([DataSourceRequest] DataSourceRequest request,
long
[] contactId)
02.
{
03.
List<DetailGridViewModel> finalList =
new
List<DetailGridViewModel>();
04.
foreach
(var conId
in
contactId)
05.
{
06.
var con = _contactService.GetContactById(conId);
07.
IEnumerable<DetailGridViewModel> coms = con.Select(x =>
new
DetailGridViewModel(x));
08.
finalList.AddRange(coms);
09.
}
10.
11.
return
Json(finalList.ToDataSourceResult(request));
12.
}
Thanks for your assistance. This is one of the few snags I have seen reviewing the product, I hope to get it resolved so I can continue my evaluation in a timely fashion!