为 jqGrid 准备数据我得到了一个意外的子网格单元格数组。简化的代码如下所示:
var result = new
{
total = 1,
page = 1,
records = qstList.Count(),
rows = qstList.Select(( c, i ) => new
{
Id = c.QuestionId,
Text = c.Text,
Type = c.Type,
Points = c.Points,
Ordinal = c.Ordinal,
subgrid = new
{
subtotal = 1,
subpage = 1,
cell = qstList.Where(
q => q.QuestionId == c.QuestionId).Select(
q => q.Answers).Select((d, j) => new
{
Id = d.Select(a => a.AnswerId),
Text = d.Select(a => a.Text),
Correctness = d.Select(a => a.Correctness),
Ordinal = d.Select(a => a.Ordinal)
}).ToArray()
}
}).ToArray()
};
行很好,但子网格的单元格数组是奇数。我期待的是:
{[Id, Text, Correctness, Ordinal], ..., [Id, Text, Correctness, Ordinal]}
但事实证明是:
{[Id, Id, ...], ..., [Ordinal, Ordinal, ...]}
如何获得预期的“布局”。谢谢你的帮助!