Telerik ASP.NET MVC Grid 在弹出模式下编辑时出现奇怪的 jscript 错误
我有一个网格,我试图在弹出模式下编辑它。弹出窗口打开正常。我在弹出窗口中又放置了两个网格。我通过 javascript ajax 调用加载它们。弹出的这两个网格也可以很好地填充。单击弹出窗口的提交(这是默认的复选标记图标)后,我收到此 Jscript 错误 “data.CancelledAMA.AgreementID 为空或不是对象”
其中 CancelledAMA 是我的模型 (ReplacementCombo) 中的自定义对象,我将其绑定到原始网格(不是弹出窗口中的 2 个网格)。并且 ContractId 是 CancelledAMA 对象中的一个 int
我已经在原始网格中尝试了 .DefaultDataItem(new ReplacementCombo()) ,以便模型对象填充默认值,并在 ReplacementCombo 模型类中创建构造函数对象。但没有任何作用。
I have a Grid, which I am trying to Edit in Pop Up mode. The pop up opens fine. I have placed two more grids within the pop up window. I load them through javascript ajax calls. These 2 grids on pop up also get populated just fine. Once I click on the submit for the pop up window (which is the default checkmark icon), I get this Jscript error
"data.CancelledAMA.AgreementID is null or not an object"
Where CancelledAMA is a custom object in my model (ReplacementCombo) that I bind to the original grid (not the 2 grids within the pop up window). And AgreementId is an int within the CancelledAMA object
I have tried the .DefaultDataItem(new ReplacementCombo()) in the original grid so that the model object gets populated with default values and created a constructor object too in the ReplacementCombo model class. But nothing works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
各位,
我很自豪地说,经过几个小时的痛苦,我发现了问题并解决了它!
吸取的教训,在 Telerik MVC 网格上,您无法从网格模型的嵌套对象中获取 DataKey。我的原始网格的数据键为 CancelledAMA.AgreementID,并且 CancelledAMA 是绑定到原始网格的模型 (ReplacementCombo) 内的嵌套对象。您只能拥有模型对象顶层属性的数据键,而不是嵌套对象的属性。
谢谢。
People,
I feel proud saying that after hours of pain, I have found the issue and resolved it!
Lesson learnt, on the Telerik MVC Grid you cannot have the DataKey from a nested object of the grid model. My original grid had the datakey as CancelledAMA.AgreementID and CancelledAMA is a nested object within the Model (ReplacementCombo) bound to the original Grid. You can only have a datakey to a property on the top level of the model object not properties of nested objects.
Thanks.