Where is my listview data

5 posts, 0 answers
  1. Bashar
    Bashar avatar
    3 posts
    Member since:
    Feb 2014

    Posted 17 Feb 2014 Link to this post

    Hi. New here.

    Below is a ListView and a DropDownList, as simple as possible, calling the same Web API for their data. 

    The DropDownList works well. The ListView does show anything. What am I doing wrong?

    The ListView API call is: http://localhost/api/vehicles?sort=&group=&filter=
    The DropDownList API call is : http://localhost/api/vehicles

    I would have assumed the .ServerOperation(false) would have removed the sort&group&filter from the Get. In any case, the JSON returned by both Gets is exactly the same. 

    Thanks

    PS: in case this is relevant, the Web API controller was generated by the Telerik Data Access Wizard and unmodified

    <script type="text/x-kendo-template" id="vehicletemplate">
        <div>
            <p>Dummy Placeholder</p>
        </div>
    </script>
     
    <div class="col-md-4">
        @(Html.Kendo().ListView<Object>().Name("VehicleList")
            .ClientTemplateId("vehicletemplate")
            .TagName("div")
            .DataSource(ds => ds
                .ServerOperation(false)
                .Read(read => read
                    .Url("/api/vehicles").Type(HttpVerbs.Get)
                )
            )
        )
     
        @(Html.Kendo().DropDownList()
            .Name("ddList")
            .DataTextField("Registration")
            .DataSource(ds => ds
                .Read(read => read
                .Url("/api/vehicles").Type(HttpVerbs.Get)
                )
            )
        )
    </div>
  2. Bashar
    Bashar avatar
    3 posts
    Member since:
    Feb 2014

    Posted 17 Feb 2014 in reply to Bashar Link to this post

    "The ListView does show anything" above should say "The ListView does NOT show anything"
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 19 Feb 2014 Link to this post

    Hello,

    The ListView expects a DataSourceResult to be returned from the server and so the data will not be bound when just the collection is returned. I would suggest to check this code-library which demonstrates how to bind the data when using the ApiControllers with the Grid. The same approach should be used for the ListView.

    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Bashar
    Bashar avatar
    3 posts
    Member since:
    Feb 2014

    Posted 20 Feb 2014 in reply to Daniel Link to this post

    Thanks Daniel.

    Does that mean there is no way for a DropDownList and a ListView to consume the same Web Api, even if I don't want any paging/filtering/sorting/grouping?

    Thanks

    Bashar
  6. Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 24 Feb 2014 Link to this post

    Hello again Bashar,

    The only option that I can currently suggest to use the same method for both the listview and the dropdownlist, is to pass a parameter with the request indicating what response should be returned from the server. For the next release we plan to make the wrappers dataSource completely customizable so it will be possible to use the schema.data option to specify in what format will the data be returned.

    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready