0

我可以让我的网格显示,但无法让我的数据填充到单元格内。这是我的网格,看起来很完美。

public static class MVCGridConfig 
{
    public static void RegisterGrids()
    {
        

        MVCGridDefinitionTable.Add("Report_Actions", new MVCGridBuilder<FMB_Reports_AllInfo_Result>()
            .WithAuthorizationType(AuthorizationType.AllowAnonymous)
            .AddColumns(cols =>
            {
                // Add your columns here
                cols.Add("Id").WithSorting(true)
                    .WithValueTemplate("<div><label>ID:</label>{Model1.PickupPath}")
                    .WithHeaderText("User ID").WithHtmlEncoding(false)
                    .WithValueExpression(p => p.Id.ToString()); // use the Value Expression to return the cell text for this column
                cols.Add("PickupPath").WithColumnName("File Location")
                    .WithValueTemplate("{Model.PickupPath}")
                    .WithHeaderText("File Locations")
                    .WithValueExpression(p => p.PickupPath);
                cols.Add("ReportDescription").WithColumnName("Report Name")
                    .WithHeaderText("Report Name")
                    .WithValueExpression(p => p.ReportDescription);
                cols.Add("DropOffPath").WithColumnName("File Destination")
                    .WithHeaderText("File Destination")
                    .WithValueExpression(p => p.DropOffPath);
                cols.Add("Active").WithColumnName("Active")
                    .WithHeaderText("Active")
                    .WithValueExpression(p => p.Active.ToString());
                cols.Add("TimeAccessed").WithColumnName("Time Accessed")
                    .WithHeaderText("Time Accessed")
                    .WithValueExpression(p => p.TimeAccessed.ToString());
                

            })
            //.WithNoResultsMessage("<div class='pad-left-20'>There are no items.</div>")
            .WithPaging(true, 30)
            .WithRetrieveDataMethod((context) =>
            {
                var options = context.QueryOptions;
                var result = new QueryResult<FMB_Reports_AllInfo_Result>();
              
                return new QueryResult<FMB_Reports_AllInfo_Result>()
                {
                    Items = new List<FMB_Reports_AllInfo_Result>(),
                    TotalRecords = 0 // if paging is enabled, return the total number of records of all pages

                };

            })
        );
        
    }
}

但是我的数据没有显示在列中。我已经按照 mvcgrid 网站上的指南进行操作,这就是我需要做的所有事情才能在这里获取我的数据。这是我的 HTML:

@using MVCGrid.Web;
<div class="panel-body">

    @Html.MVCGrid("Report_Actions")

</div>
4

1 回答 1

1

我只是自己回答这个问题,因为我终于发现了为什么我的数据没有显示而且很愚蠢的主要问题。因此,如果有人做同样的事情,希望这会在几年或几个月内找到喜欢的人。

cols.Add("Id").WithSorting(true)
                .WithValueTemplate("<div><label>ID:</label>{Model1.PickupPath}")
                .WithHeaderText("User ID").WithHtmlEncoding(false)
                .WithValueExpression(p => p.Id.ToString()); // use the Value

在 .WithValueTemplate() 我删除了 div 和标签,一切都很完美。我没有引用正确的东西,所以它没有抛出错误,但它会在调试时停止。

于 2020-09-01T21:05:12.597 回答