【问题标题】:Get items with Active == true only仅获取带有 Active == true 的项目
【发布时间】:2013-10-18 13:54:03
【问题描述】:

我使用 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

【问题讨论】:

  • gridData.Where(c => c.Item.Active).Select(... 不行吗?
  • @allo_man 我不确定
  • 这导致您不想要的行为是什么?
  • 对不起,它确实有效,谢谢你的帮助。

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


【解决方案1】:

您可以简单地将行的选择更改为

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-24
    • 1970-01-01
    • 2020-11-07
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    相关资源
    最近更新 更多