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

Where is my listview data

4 Answers 152 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Bashar
Top achievements
Rank 1
Bashar asked on 17 Feb 2014, 08:57 PM
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>

4 Answers, 1 is accepted

Sort by
0
Bashar
Top achievements
Rank 1
answered on 17 Feb 2014, 09:00 PM
"The ListView does show anything" above should say "The ListView does NOT show anything"
0
Daniel
Telerik team
answered on 19 Feb 2014, 04:43 PM
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!
0
Bashar
Top achievements
Rank 1
answered on 20 Feb 2014, 08:14 PM
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
0
Daniel
Telerik team
answered on 24 Feb 2014, 09:56 AM
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!
Tags
ListView
Asked by
Bashar
Top achievements
Rank 1
Answers by
Bashar
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or