Orchard CMS:如何将DriverResult显示重载为@model并支持绑定?
ARG!在过去的两天里,我在这里敲打了大约 18 个小时,就像试图在一个 4 英尺长的粘泥池中跑步一样……我已经非常接近了,担心我将不得不在周一步行,但没有任何结果为了我所有的劳动...
大图:
我有一个小部件,需要考虑用户的邮政编码,并基于此提供其区域内的事件列表。
如果 GeoIp 查找已关闭,或者用户有兴趣查找其他位置,他们可以将 ZipCode 更改为他们选择的任何内容并“回发”,从而使模块重新绘制。
我有从另一个数据库查找的小部件并作为小部件渲染得很好。
我让一切都按照我想要的方式工作。我“认为”我想要的是成为
protected override DriverResult Display(
SeminarPart part, string displayType, dynamic shapeHelper) {
我可以在 .cshtml 中绑定到的东西
@model CustomPart
,但无论我做什么,我都会得到 ->
传入字典的模型项是类型 'IShapeProxyabb0e4251c0b4c71bfe70f2ec47bfca4',但是这个字典 需要类型为“Blah.Blah.MoreBlah.CustomPart”的模型项。
如果我能得到所有这些快乐,我“认为”我将能够做类似的事情
@Html.TextBoxFor(m=>m.SelectedZipCode)
最终模型将刷新其结果集,更改模型中的 List
并重新绘制名单...???
DANGDED 编辑器部分公开了 GET 和 POST DriverResult
编辑器,并且似乎做了我希望在这里可以做的事情......有人有想法吗?
PPPPPPPLLLLLLLEEEEEASSE 罗杰....提前非常感谢,-James 等 10-Geek dot com...
ARG! I am beating my head here for like 18 hrs over last 2 days, been like trying to run in a 4' pool of stucky mud... I am sooooo close and fear I am going to have to walk in Monday with a NON result for all my labor...
Big picture:
I have a widget that needs to consider the users zipcode, and based on this provide a list of events within their area.
If the GeoIp lookup is off, or the users is interested in looking else where they can reach up and change the ZipCode to any of their choosing and "postback", having the modules redraw.
I have the widgets looking up from another DB and rendering just fine as a widget.
I have it all working just as I want.. I "think" what I want is for the
protected override DriverResult Display(
SeminarPart part, string displayType, dynamic shapeHelper) {
to be something I can bind to in the .cshtml
@model CustomPart
but no matter what I do I get ->
The model item passed into the dictionary is of type
'IShapeProxyabb0e4251c0b4c71bfe70f2ec47bfca4', but this dictionary
requires a model item of type 'Blah.Blah.MoreBlah.CustomPart'.
If I can get all of this happy, I "THINK" I would be able to do something like
@Html.TextBoxFor(m=>m.SelectedZipCode)
And ultimately then the model would refresh its result set, changing the List<CustomData>
in the model and redrawing the list... ???
The DANGDED editor part exposes GET and POST DriverResult
Editor and seems to do what I had hoped I could do here... anyone, ideas?
PPPPPPLLLLLLEEEEEASSE Roger.... much thanks in advance, -James et 10-Geek dot com...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将您的
@model CustomPart
替换为@modeldynamic
。传递给视图的模型已被 Orchard 代理以允许它执行某些操作,并且代理对象是动态的,而不是 CustomPart 的实例。这仅适用于通过 Display(...) 方法显示的视图。在用于
Editor(CustomPart part,dynamic shapeHelper)
方法的视图中,您应该使用@model CustomPart
。Replace your
@model CustomPart
with@model dynamic
. The Model passed to the view has been proxied by Orchard to allow it to do some stuff, and the proxied object isdynamic
, NOT an instance ofCustomPart
.This only applies to views displayed via the
Display(...)
method. In the view used for yourEditor(CustomPart part, dynamic shapeHelper)
method, you should use@model CustomPart
.