Listview not showing data

3 posts, 0 answers
  1. Leroy
    Leroy avatar
    3 posts
    Member since:
    May 2013

    Posted 27 May 2013 Link to this post

    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. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 28 May 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Leroy
    Leroy avatar
    3 posts
    Member since:
    May 2013

    Posted 28 May 2013 Link to this post

    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);
     
Back to Top