This is a migrated thread and some comments may be shown as answers.

Listview not showing data

2 Answers 506 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Leroy
Top achievements
Rank 1
Leroy asked on 27 May 2013, 07:05 PM
Hello,

I followed every step like the mvc  examples to try to bind a list view.

My setup is as follows:       

The Controller:
public ActionResult Scans_Read([DataSourceRequest] DataSourceRequest request)
{
    return Json(GetScans().ToDataSourceResult(request));
}
private static IEnumerable<ScanModel> GetScans()
        {
            var ec = new entityContext();
            return ec.tScan.Select(scanmodel => new ScanModel
            {
                scanId = scanmodel.scanId,
                description = scanmodel.description,
                directoryPath = scanmodel.directoryPath
            });
        }
 The Model:
public class ScanModel
    {
        [ScaffoldColumn(false)]
        public int scanId
        {
            get;
            set;
        }
 
        [Required]
        [DisplayName("description")]
        public string description
        {
            get;
            set;
        }
 
        [Required]
        [DisplayName("directoryPath")]
        public string directoryPath
        {
            get;
            set;
        }
    }
The view:
@model IEnumerable<ns.Models.ScanModel>
<script type="text/x-kendo-tmpl" id="template">
    <div class="scanmodel">
        <h3>#:description#</h3>
    </div>
</script>
@(Html.Kendo().ListView<ns.Models.ScanModel>(Model)
    .Name("listView")
    .TagName("div")
    .ClientTemplateId("template")
    .DataSource(dataSource => {
        dataSource.Read(read => read.Action("Scans_Read", "CustomerPortal"));
    })
)
This is practically the same as in the example.

But it doesn't display data. 

The resultset from "return Json(GetScans().ToDataSourceResult(request));" does contain the dataset.

What am I doing wrong here...!

Thanks,

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 28 May 2013, 06:27 AM
Hello Leroy,

That is odd behavior that you are experiencing. The ListView setup looks correct to me. 
When you inspect the browser console `Network` tab do you see the response from the read action method returned?

Another thing that you can check is which scripts are registered and whether the order of inclusion is correct. The script section should looks as follow:

<script src="<%= Url.Content("~/Scripts/jquery.min.js") %>"></script>
<script src="<%= Url.Content("~/Scripts/kendo.web.min.js") %>"></script>
<script src="<%= Url.Content("~/Scripts/kendo.aspnetmvc.min.js") %>"></script>

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Leroy
Top achievements
Rank 1
answered on 28 May 2013, 06:56 PM
Hello Nikolay,

Thanks for the response.

I found the issue.  It was due to the fact the request behavior was set to "AllowGet".
return Json(result,JsonRequestBehavior.AllowGet);
 
Tags
ListView
Asked by
Leroy
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Leroy
Top achievements
Rank 1
Share this question
or