Kendo Grid: Toolbar template issue

旧街凉风 提交于 2019-12-06 03:26:24

change this

return Json(aux.concessions.Select(c => c.concession.mediumDescription).Distinct(), hJsonRequestBehavior.AllowGet);

to

return Json(aux.concessions.Select(c => new ConcessionModel { Description = c.concession.mediumDescription }).Distinct(), JsonRequestBehavior.AllowGet);

First, double check what Json you are returning from the controller method. It looks like your ConcessionMediumDescriptions may have no data in them.

Second, it looks like, in your controller, that you are returning a list of "ConcessionMediumDescription" data objects.

I am guessing it looks like this...

{ConcessionMediumDescription: {
  CCode: 'mycode',
  ...
  }
}

You may consider returning a title field as a part of this Json and to use that for the text field of your dropdown. This is just me guessing from what you are returning in that controller.


Ideal Json would be somting like this...

[{
  {{id: 'id1'},{text: 'text1'}},
  {{id: 'id2'},{text: 'text2'}}
}]

And you defind your dropdown as such.

.DataTextField("text")
.DataValueField("id")

You have to do json return line like this.

return Json(aux.concessions.Select(c => new { Value = c.concession.DATAVALUE, Text = c.concession.DATATEXT }), JsonRequestBehavior.AllowGet);

Just change DATAVALUE and DATATEXT

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!