当ASPxSummaryItem中的值为0时,隐藏ASPxGridView中的列

问题描述 投票:1回答:1

这是我有我的gridview的地方:

<dx:ASPxGridView ID="GridViewID" runat="server" DataSourceID="SourceMain" ClientInstanceName="Grid" SettingsPager-mode="ShowAllRecords" OnHtmlDataCellPrepared="ASPxGridView1_HtmlDataCellPrepared">
 <Columns>
     <dx:GridViewDataTextColumn FieldName="TrackOutDate" VisibleIndex="1" Visible="True"><PropertiesTextEdit DisplayFormatString="MM/dd/yyyy"></PropertiesTextEdit></dx:GridViewDataTextColumn>
     <dx:GridViewDataTextColumn FieldName="LotID" VisibleIndex="2" Visible="True"></dx:GridViewDataTextColumn>
     <dx:GridViewDataTextColumn FieldName="Qty_IN" VisibleIndex="11" Visible="True"></dx:GridViewDataTextColumn>
     <dx:GridViewDataTextColumn FieldName="HX" VisibleIndex="12" Visible="True"></dx:GridViewDataTextColumn>
     <dx:GridViewDataTextColumn FieldName="NA" VisibleIndex="13" Visible="True"></dx:GridViewDataTextColumn>
 </Columns>
    <Settings ShowFooter="true" />
    <TotalSummary> 
    <dx:ASPxSummaryItem FieldName="Qty_IN" SummaryType="Sum" DisplayFormat="{0}" Tag="1" ShowInColumn="Qty_IN"  />
    <dx:ASPxSummaryItem FieldName="HX" SummaryType="Sum" DisplayFormat="{0}"/>
    <dx:ASPxSummaryItem FieldName="NA" SummaryType="Sum" DisplayFormat="{0}"/>
    </TotalSummary>
</dx:ASPxGridView>

这是填写gridview的代码:

protected void SourceMain_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    lote = getLot();
    device = getDevice();
    stage = getStage();
    location = getLocation();
    equipment = getEquipment();
    SD = Convert.ToDateTime(getStartDate());
    ED = Convert.ToDateTime(getEndtDate());

    MetricsPortal.DAL.ReportsDataClassesDataContext dataContext = new MetricsPortal.DAL.ReportsDataClassesDataContext();
    e.Result = (from items in dataContext.CalculateDailyYieldequipmentParam(lote,device,stage,location,equipment,SD,ED,Evaluation())
                orderby items.TrackOutDate ascending, items.GRANDTOTAL1 descending
                //where items.GRANDTOTAL1 > 0
                select items).Distinct();

}//source Main

当这些列的总摘要为0时,是否可以删除或隐藏列?

例如:enter image description here

在黄色列中,值为0,在这种情况下我可以隐藏此列吗?什么时候不是0只显示列?

c# asp.net tsql devexpress
1个回答
0
投票

实际上onselected事件更合适,只要GridView1.Columns[yourcolumnindex].Visible = false;和列将消失。

© www.soinside.com 2019 - 2024. All rights reserved.