Hi, has anyone a running sample of a ListView? Here is my code
the returning json from OnPostReadThumbnails looks good, but the ListView is emtpy
{
"data"
:[{
"slfd"
:
"0"
,
"sdatname"
:
"Test"
}],
"total"
:1,
"aggregateResults"
:
null
,
"errors"
:
null
}
cshtml.cs
public
class
IndexModel : PageModel
{
private
readonly
ILogger<IndexModel> _logger;
public
static
IList<ThumbnailViewModel> thumbs;
public
IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}
public
void
OnGet()
{
if
(thumbs ==
null
)
{
thumbs =
new
List<ThumbnailViewModel>();
thumbs.Add(
new
ThumbnailViewModel { SLFD =
"0"
, SDATNAME =
"Test"
});
}
}
public
JsonResult OnPostReadThumbnails([DataSourceRequest] DataSourceRequest request)
{
return
new
JsonResult(thumbs.ToDataSourceResult(request));
}
}
cshtml
<
script
type
=
"text/x-kendo-tmpl"
id
=
"template"
>
<
div
class
=
"product"
>
<
h3
>#:SDATNAME#</
h3
>
<
h1
>#=SLFD#</
h1
>
<
h2
>SDATNAME</
h2
>
</
div
>
</
script
>
<
div
class
=
"demo-section k-content wide"
>
@(Html.Kendo().ListView<
Data.ThumbnailViewModel
>()
.Name("listView")
.TagName("div")
.ClientTemplateId("template")
//.Scrollable(ListViewScrollableMode.Endless)
.DataSource(ds => ds.Ajax()
.Read(read => read.Url("/Index?handler=ReadThumbnails").Data("forgeryToken"))
)
.Pageable()
)
</
div
>