获取仅有Active == true的项目

时间:2013-10-18 13:54:04

标签: c# asp.net-mvc-4 jqgrid

我使用MVC jqGrid创建网格,这是我填充网格的代码

var jsonData = new
        {
            total = formTemplatePage.TotalEntriesCount / (pageSize + childrenCount) + 1,
            page = gridSettings.PageIndex,
            rows = (
                       gridData.Select(c => new
                       {
                           id = c.Item.Id,
                           cell = new[]
                                                                    {
                                                                        c.Number,
                                                                        c.Item.Name,
                                                                        c.Item.Id.ToString(), 
                                                                        c.Item.Active.ToString(),
                                                                        c.Level,
                                                                        c.ParentId,
                                                                        c.IsLeaf,
                                                                        c.Expanded,
                                                                        c.UnKnown,
                                                                    }
                       })).ToList()
        };

但我怎样才能获得c.Item.Active == true

1 个答案:

答案 0 :(得分:1)

您只需将行选择更改为

即可
gridData.Where(c => c.Item.Active).Select([...]);