【发布时间】:2013-12-11 13:13:09
【问题描述】:
我通过对 mvc 控制器的 ajax 调用来总结 json。 JSON 包含一个属性,即 just 和 int。另一个属性是objects 的集合,objects 本身具有otherobjects 的集合,otherojbect 的属性是promitive 类型。问题是,如果我仅汇总该 json 的第二个属性(复杂 objects 的集合)模型绑定器会做得非常好并将其绑定到模型但是当我提交 objects 的集合时原始 int 模型绑定器仅绑定 int 属性,而 seccond 属性只是空集合。我使用 ext-js ajax 调用。我尝试使用params 属性和jsonData 属性提交json,似乎没有任何效果?这个问题的最佳解决方案是什么。任何帮助都会得到帮助。
public class ModelToBind
{
public int IntParam { get; set; }
public IEnumerable<CompexObject> ComplexObjectParam { get; set; }
}
public class CompexObject
{
public int AnotherIntProp { get; set; }
IEnumerable<AnotherComplexObject> AnotherComplexObject{ get; set; }
}
public class AnotherComplexObject
{
// some primitive properties here
}
public JsonData DoSomething(ModelToBind model)
{
model.IntParam; // this property is binded
model.ComplexObjectParam; // this is binded as empty collection
}
【问题讨论】:
-
请发布您的代码。
-
这里是核心@Maess
-
发布您的 javascript 并查看
-
它是 javasvript 问题的可能性很大吗?因为我认为所有内容都发布得很安静,这是一个模型粘合剂问题。我无法发布 javascript。为什么需要 view ?我@Maess
-
这可能是您发布数据的方式有问题,因此希望查看 js 或查看代码。
标签: c# asp.net-mvc json extjs model-binding