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

ListView not showing template

1 Answer 132 Views
ListView
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 18 Nov 2015, 04:50 PM

I have a very simple listview that I cannot get to show any data. 

 View:

@(Html.Kendo().ListView<PortalContext.Root>()
                    .Name("leafView")
                    .TagName("div")
                    .ClientTemplateId("leafTemplate")                
                            .DataSource(dataSource => {
                                dataSource.Model(model => { model.Id(p => p.RootId);
                                                            model.Field<string>(f => f.ShortName);
                                });
                                dataSource.Read(read => read.Action("Leafs", "Home").Data("branchLevel"));
                            })
                )

 

    <script type="text/x-kendo-tmpl" id="leafTemplate">       
        <div style="height:100px">
            #: ShortName #
        </div> 
    </script>

I have a treeview that refreshes the data onSelect

 

function onSelect(e) {
        if (treeview.dataItem(e.node).IsBranch) {
            branchId = treeview.dataItem(e.node).id;            
            $("#leafView").data("kendoListView").dataSource.read();
        }
    }

    function branchLevel() {
        return {
            branchId: branchId            
        };
    }

I have simplified a few things but my controller looks like this and is basically returning a list of objects.

public ActionResult Leafs([DataSourceRequest]DataSourceRequest request, int? branchId) {

            return Json(ViewModel.Roots.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

 

Any ideas why this may not be working?

 

Bill

1 Answer, 1 is accepted

Sort by
0
William
Top achievements
Rank 1
answered on 18 Nov 2015, 10:51 PM
This has been resolved. 
Tags
ListView
Asked by
William
Top achievements
Rank 1
Answers by
William
Top achievements
Rank 1
Share this question
or