NGridView使用介绍

Nello.Web.Controls.NGridView继承自System.Web.UI.WebControls.GridView,并对后者做了一定的扩展,具体内容如下:
1、显示合计行。利用属性NeedSumColIndexes来实现,该属性指需要汇总的列的索引,如1,5,10,其中第一列显示[合计:]
<nello:NGridView id="NGridView1" runat="server" NeedSumColIndexes="1,10" >
    <Columns>
        <asp:BoundField DataField="Billguid" HeaderText="Billguid" />
        <asp:BoundField DataField="billno" HeaderText="单据编号" />
        <asp:BoundField DataField="billtype" HeaderText="单据类型" />
        <asp:BoundField DataField="billmanid" HeaderText="billmanid" Visible="false" />
        <asp:BoundField DataField="fusername" HeaderText="制单人" />
        <asp:BoundField DataField="billdate" HeaderText="单据日期" />
        <asp:BoundField DataField="providerguid" HeaderText="providerguid" Visible="false"  />
        <asp:BoundField DataField="providername" HeaderText="供应商" />
        <asp:BoundField DataField="depotguid" HeaderText="depotguid" Visible="false"  />
        <asp:BoundField DataField="depotname" HeaderText="仓库" />
        <asp:BoundField DataField="totalmoney" HeaderText="总金额" >
        <ItemStyle HorizontalAlign="Right" />
        </asp:BoundField>
    </Columns>
    <SelectedRowStyle BackColor="Blue" ForeColor="White" />
    <HeaderStyle BackColor="Navy" ForeColor="White" />
</nello:NGridView>

 

2、点击以选中行。利用属性FullRowSelect来实现,该属性指是否整行选择
<nello:NGridView id="NGridView1" runat="server" FullRowSelect="True" >
    <Columns>
        <asp:BoundField DataField="Billguid" HeaderText="Billguid" />
        <asp:BoundField DataField="billno" HeaderText="单据编号" />
        <asp:BoundField DataField="billtype" HeaderText="单据类型" />
    </Columns>
    <SelectedRowStyle BackColor="Blue" ForeColor="White" />
    <HeaderStyle BackColor="Navy" ForeColor="White" />
</nello:NGridView>

 

3、是否隐藏第一列。利用属性HideFirstColumn 来实现,该属性指隐藏第一列
<nello:NGridView id="NGridView1" runat="server" HideFirstColumn="True" >
    <Columns>
        <asp:BoundField DataField="Billguid" HeaderText="Billguid" />
        <asp:BoundField DataField="billno" HeaderText="单据编号" />
        <asp:BoundField DataField="billtype" HeaderText="单据类型" />
    </Columns>
    <SelectedRowStyle BackColor="Blue" ForeColor="White" />
    <HeaderStyle BackColor="Navy" ForeColor="White" />
</nello:NGridView>

 

4、限制一个单元格内最多显示的字符数。利用属性LimitCellChars和MaxCellChars来实现,前者指是否限制一个单元格内最多显示的字符数,后者指一个单元格内最多显示的字符数,默认为16
<nello:NGridView id="NGridView1" runat="server" LimitCellChars="True" MaxCellChars="16">
    <Columns>
        <asp:BoundField DataField="Billguid" HeaderText="Billguid" />
        <asp:BoundField DataField="billno" HeaderText="单据编号" />
        <asp:BoundField DataField="billtype" HeaderText="单据类型" />
    </Columns>
    <SelectedRowStyle BackColor="Blue" ForeColor="White" />
    <HeaderStyle BackColor="Navy" ForeColor="White" />
</nello:NGridView>

 

5、导出Excel时数字作为文本显示的列的索引,如1,4,7,8。利用属性NumberAsTextColIndexes来实现。
<nello:NGridView id="NGridView1" runat="server" NumberAsTextColIndexes="1,4,7" >
    <Columns>
        <asp:BoundField DataField="Billguid" HeaderText="Billguid" />
        <asp:BoundField DataField="billno" HeaderText="单据编号" />
        <asp:BoundField DataField="billtype" HeaderText="单据类型" />
    </Columns>
    <SelectedRowStyle BackColor="Blue" ForeColor="White" />
    <HeaderStyle BackColor="Navy" ForeColor="White" />
</nello:NGridView>

 

6、得到指定列的汇总数。利用方法 double GetTotals(int colIndex)来实现,参数colIndex指列的索引。

 

7、设置指定列的CssClass,如 .CssHideMe{display:none;},利用方法 void SetColumnCssClass(int colIndex, string css)来实现,参数colIndex指列的索引,css指Css类名。

 

8、将网格数据导出至Excel。调用此方法须先后对网格控件做必要的设置(如隐藏不需要导出的列,并在导出后恢复显示),并将页面的VerifyRenderingInServerForm方法重载为空方法,意为忽略对控件是否在服务器端窗体中呈现进行验证。如不设置文件名参数,则默认为name.xls

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值