asp.net mvc - Kendo TreeView sequence contains no elements error -


while using kendo treeview server side data there issue while binding data in mvc

my controller action is:

public actionresult daypart(long storeid)         {                 ienumerable<treeviewmapmodel> objdaypart = item in new daypartservice().getall().tolist()                                                        select new treeviewmapmodel                                                        {                                                            id = item.id,                                                            name = item.name,                                                            items = (from map in new daypartmappingservice().getbystoreid(storeid)                                                                     item.id == map.daypartid                                                                     select new mastermodel() { id = int.parse(map.sourceid), name = map.sourcelabel }).tolist(),                                                         };   var ret = objdaypart.select(x => new treeviewmapmodel            {                haschildren = x.items.count() > 0,                id = x.id,                items = x.items ?? enumerable.empty<mastermodel>(),                name = x.name            }); @viewbag.storename = new storeservice().getbyid(storeid).name;           return view(ret);         } 

and in view

@model ienumerable<apis.web.mvcportal.areas.setups.models.treeviewmapmodel>  @(html.kendo().treeview() .name("right-treeview") .bindto(model.tolist(), (kendo.mvc.ui.fluent.navigationbindingfactory<treeviewitem> mappings) => {     mappings.for<apis.web.mvcportal.areas.setups.models.treeviewmapmodel>(bound => bound.itemdatabound((node, structure) =>     {         node.haschildren = structure.haschildren;         node.id = structure.id.tostring();         node.text = structure.name;         })      .children(structure => structure.items)); })         ) 

but getting error sequence contain no elements.can tell m doing wrong.

my stack trace is: @ system.linq.enumerable.first[tsource](ienumerable1 source) @ kendo.mvc.ui.navigationitemcontainerextensions.bind[tnavigationitem](tnavigationitem component, object dataitem, navigationbindingfactory1 factory) @ kendo.mvc.ui.navigationitemcontainerextensions.bind[tnavigationitem](tnavigationitem component, object dataitem, navigationbindingfactory1 factory) @ kendo.mvc.ui.navigationitemcontainerextensions.bindto[tnavigationitem](inavigationitemcontainer1 component, ienumerable datasource, action1 factoryaction) @ kendo.mvc.ui.fluent.treeviewbuilder.bindto(ienumerable datasource, action1 factoryaction) @ asp._page_areas_setups_views_mapping_daypart_cshtml.execute() in d:\apisbi_mvc\apisbi\main\src\apis.web.mvcportal\areas\setups\views\mapping\daypart.cshtml:line 47 @ system.web.webpages.webpagebase.executepagehierarchy() @ system.web.mvc.webviewpage.executepagehierarchy() @ system.web.webpages.webpagebase.executepagehierarchy(webpagecontext pagecontext, textwriter writer, webpagerenderingbase startpage) @ system.web.mvc.razorview.renderview(viewcontext viewcontext, textwriter writer, object instance) @ system.web.mvc.buildmanagercompiledview.render(viewcontext viewcontext, textwriter writer) @ system.web.mvc.viewresultbase.executeresult(controllercontext context) @ system.web.mvc.controlleractioninvoker.invokeactionresult(controllercontext controllercontext, actionresult actionresult) @ system.web.mvc.controlleractioninvoker.<>c_displayclass1a.b_17() @ system.web.mvc.controlleractioninvoker.invokeactionresultfilter(iresultfilter filter, resultexecutingcontext precontext, func`1 continuation)

thanks in advance.

i got similar error when children's object datatypes not converted same type being passed grid.

for example, in case came service list converted more generic list -- children sitting on each tag still tags.

i either needed recursive function convert child tags ourtreeitemclass or alternatively, create service method returns data ourtreeitemclass in first place alleviate need these conversions @ all.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -