Kendo MVC包装纸网格。如何指定嵌套模型字段的数据类型?
我有数百个网格的项目工作。特别是在一个网格上,原始设计师创建了一个视图,并将其添加为驱动器模型中的嵌套模型。这是一个问题,因为Kendo似乎无法检测以这种方式嵌套的字段类型。当它不能时,它假设字段是字符串。
在我的特殊情况下,我有两个字段,其中包含我们要过滤的日期,但是由于此,日期过滤被打破了。
我能够找到许多在数据源中指定它的示例,但仅用于jQuery网格(一个示例: https://docs.telerik.com/kendo-ui/knowledge-base/use-nested-model-properties )。我无法将其转换为MVC,因为这些方法没有排队。
关于如何在MVC中执行此操作的任何想法?注意:我还尝试将过滤器上的UI更改为迄今为止,但这也不起作用。我有一个堆栈跟踪声称需要的日期是字符串。
I have a project work work with hundreds of grids. On one grid in particular, the original designer created a view and added it as a nested model inside our driver model. This is a problem because Kendo seems to not be able to detect the field type of a field nested this way. When it can't, it assumes the field is a string.
In my particular case, I have two fields that contain dates that we want to filter on, but the date filtering is broken because of this.
I was able to find numerous examples of specifying it in the data source, but only for jquery grids (one example: https://docs.telerik.com/kendo-ui/knowledge-base/use-nested-model-properties ). I can't convert this to mvc because the methods aren't lining up.
Any idea on how to do this in mvc? Note: I also tried just changing the UI on the filter to date and that didn't work either. I got a stack trace claiming date needed to be a string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我了解,传递给网格字段的模型是这样的:
然后您可以使用 clientTemplate配置要获取CityName填充列:
有关更多信息,请参阅 Kendo UI模板文章
或者
此论坛答案显示网格的数据源模型配置中的嵌套字段。
As far as I understand the model passed to the Grid's field is structured like this:
Then you can utilize the ClientTemplate configuration to get the CityName to populate the column:
For more information refer to the Kendo UI Templates article
or
this forum answer that shows how to set a default to a nested field in a Grid's DataSource Model configuration.
不幸的是,根据Telerik的说法,事实是您根本无法做我想做的事情。解决方案是将模型弄平。我将可疑的字段拉到了主模型中的未映射字段中。
他们回应的相关部分:
链接: https://www.telerik.com/forums/kendo-mvc-wrapper-grid-how-do-i-pecify-the-the-data-type-the-data-type of-a-a-nested-model-field
这里的警告是,您不能将linq-for for linq-for for linq-for cerquies dataSource过滤到一个未映射的字段,因为它不存在,但就我而言,.tolist()并未导致任何性能问题,因为数据集很小,只有几百个记录。
但是,您可以编辑传入的dataSourcerequest对象,以修改过滤器并在控制器读取后指向子模型。
Unfortunately, according to Telerik , the fact is that you simply can't do what I was trying to do. The solution is to flatten the model. I pulled the questionable fields into notmapped fields in the master model.
The relevant part of their response:
Link: https://www.telerik.com/forums/kendo-mvc-wrapper-grid-how-do-i-specify-the-data-type-of-a-nested-model-field
The caveat here is you can't filter a linq-for-queries datasource to a notmapped field because it doesn't exist in it but in my case, a .toList() didn't cause any performance problems because the dataset was small, with only a few hundred records.
However, you can edit the incoming DatasourceRequest object to modify the filters and sorts to point at the sub model, after your controller read is hit.