我正在使用GridMvc来填充文档详细信息。下面是视图中的GridMvc代码:
<div style="width:5000px;">
@Html.Grid(Model.allDocs).Columns(columns =>
{
columns.Add(c => c.SourceFileName).Titled("SourceFileName").Filterable(true).Sanitized(false).Encoded(false)
.RenderValueAs(o => Html.ActionLink(o.SourceFileName, "Download", "FormAdmin", new { Id = o.DataFileID }, new { target = "_blank" }).ToHtmlString());
columns.Add(c => c.ID).Titled("ID");
//columns.Add(c => c.SourceFileName).Titled("SourceFileName").Filterable(true);
columns.Add(c => c.Createdate).Titled("CreateDate");
columns.Add(c => c.customerName).Titled("customerName");
columns.Add(c => c.CompanyName).Titled("CompanyName");
}).WithPaging(3).Sortable(true)
</div>
以下是我在控制器中的代码:
public ActionResult DocDetails()
{
DocViewModel obj = new DocViewModel();
obj.allDocs = new DocumentDetailsModel().GetDocumentViewModel();
obj.ClientCodeLst = new DocumentDetailsModel().GetClientViewModel().ClientCodeLst;
// obj.allSearch = new SearchParameters();
obj.searchParam = new SearchParameters();
return View(obj);
}
[HttpPost]
public ActionResult DocDetails(DocViewModel b)
{
DocViewModel obj2 = new DocViewModel();
//if (ModelState.IsValid)
//{
obj2.allDocs = new DocumentDetailsModel().GetDocumentbySearch(b.searchParam.ID);
obj2.ClientCodeLst = new DocumentDetailsModel().GetClientViewModel().ClientCodeLst;
obj2.searchParam = new SearchParameters();
//}
return View(obj2);
}
用户选择特定值并使用特定于这些值的记录填充网格。 获取值并使用这些数据填充网格后,当用户单击分页以获取下一个记录数据集时,网格将填充所有默认数据,但不会导航到具有特定值的下一组数据。
有人能让我知道我在哪里理解概念吗?
更新:
public List<GetDocumentsParam> GetDocumentViewModel()
{
var fnResult1 = new List<GetDocumentsParam>();
var edmx = new RepositoryEntities1();
var getDocs = new GetDocumentsParam();
return fnResult1 ;
}
public GetClientCodes GetClientViewModel()
{
var fnResult = new GetClientCodes();
var edmx = new RepositoryEntities1();
fnResult.ClientCodeLst = edmx.Clients
.Select(s => s.ClientCode)
.Distinct()
.Select(s => new SelectListItem { Text = s, Value = s }).ToList();
return fnResult;
}
public List<GetDocumentsParam> GetDocumentbySearch(DateTime date)
{
fnResult = new List<GetDocumentsParam>();
//GetDocumentsParam objDoc = new GetDocumentsParam();
var objDoc1 = (from c in db.DFiles
join b in db.BDatas
on c.ID equals b.ID
join d in db.Documents
on c.ID equals d.ID
where d.CreateDate == date
select new GetDocumentsParam
{
ID = c.ID,
SourceFileName = c.SourceFileName,
Createdate = c.CreateDate,
CompanyName = c.CompanyName,
CustomerName = c.CustomerName,
ClientCode = c.ClientCode
});
fnResult = objDoc1.ToList();
// fnResult = queryResults;
return fnResult;
}
public class DocViewModel
{
public List<GetDocumentsParam> allDocs { get; set; }
public List<SelectListItem> ClientCodeLst { get; set; }
public SearchParameters searchParam { get; set; }
}