【WTM框架】查询列表显示正常,但是导出的时候查询条件不起作用的问题记录及解决方法
问题描述
添加了一个查询列表,输入关键字查询都正常,但是导出的时候,查询条件没有起到作用,把所有的数据都查出来了。
出现问题当时的场景描述:
建了一个这个类:
public class PurchaseOrderDetailAndListGroup { public PurchaseOrderMainVM Main { get; set; } public PurchaseOrderDetailListVM DetailList { get; set; } }
然后把这个类传到前台:
var vm = CreateVM<PurchaseOrderMainVM>(id); var ListData = CreateVM<PurchaseOrderDetailListVM>(); PurchaseOrderDetailAndListGroup group = new PurchaseOrderDetailAndListGroup(); group.Main = vm; group.DetailList = ListData; return PartialView(group);
前台用的时候:
@model TS_DataBridgeMainWeb.ViewModel.PurchaseOrder.PurchaseOrderMainVMs.PurchaseOrderDetailAndListGroup @inject IStringLocalizer<WalkingTec.Mvvm.Core.Program> Localizer; <wt:form vm="Main"> <wt:row items-per-row="ItemsPerRowEnum.Three"> <wt:display field="Main.Entity.ordercode" /> <wt:display field="Main.Entity.shopcode" /> </wt:row> </wt:form> <wt:searchpanel vm="DetailList" reset-btn="true"> <wt:row items-per-row="ItemsPerRowEnum.Three"> <wt:textbox field="DetailList.Searcher.ordercode" default-value="@Model.Main.Entity.ordercode" /> </wt:row> </wt:searchpanel> <wt:grid vm="DetailList" url="/PurchaseOrder/PurchaseOrderMain/SearchDetail" hidden-checkbox="true" /> <wt:row align="AlignEnum.Center"> <wt:closebutton /> </wt:row>
解决方法
把“PurchaseOrderDetailListVM”做为model传到前台,然后另外一个实体,使用ViewBag的方法上传,如下:
var vm = CreateVM<ReturnedPurchaseOrderMainVM>(id); var ListData = CreateVM<PurchaseOrderDetailListVM>(); ViewBag.MainData = vm; return PartialView(ListData);
@model TS_DataBridgeMainWeb.ViewModel.ReturnedPurchaseOrder.PurchaseOrderMainVMs.PurchaseOrderDetailListVM @inject IStringLocalizer<WalkingTec.Mvvm.Core.Program> Localizer; @{ var Main = (TS_DataBridgeMainWeb.ViewModel.ReturnedPurchaseOrder.ReturnedPurchaseOrderMainVMs.ReturnedPurchaseOrderMainVM)ViewBag.MainData; } <wt:form vm="@Main"> <wt:row items-per-row="ItemsPerRowEnum.Three"> <wt:display field="@Main.Entity.code" /> <wt:display field="@Main.Entity.shopcode" /> </wt:row> </wt:form> <wt:searchpanel vm="@Model" reset-btn="true"> <wt:row items-per-row="ItemsPerRowEnum.Three"> <wt:textbox field="Searcher.code" default-value="@Main.Entity.code" /> </wt:row> </wt:searchpanel> <wt:row items-per-row="ItemsPerRowEnum.One"> <div style="padding:0px; margin:0px; height:350px;"> <wt:grid vm="@Model" url="/PurchaseOrder/PurchaseOrderMain/SearchDetail" hidden-checkbox="true" /> </div> </wt:row> <div style="margin-top:30px;"> <wt:row align="AlignEnum.Center"> <wt:closebutton /> </wt:row> </div>