ASP.NET-FineUI开发实践-10
嵌套Grid,光棍月大放送,不藏着掖着。实在写的不好,没脸藏啊~只考虑显示排序修改什么的都不管!
<f:TemplateField ColumnID="griditem" Hidden="true" RenderAsRowExpander="true"> <ItemTemplate> <div runat="server" id="divItem" class="expander"> </div> </ItemTemplate> </f:TemplateField>
F(‘<% =Grid1.ClientID%>‘).view.on(‘expandBody‘, function (rowNode, record, expandRow, eOpts) { //传到后台,参数为行ID,行绑定的数据ID F.customEvent(‘GridItem_‘ + rowNode.id + ‘_‘ + record.get(‘ItemId‘)); });
<f:Panel runat="server" ID="PanelGrid1" Height="0px" Hidden="false"> <Items> <f:Grid ID="Grid2" Width="200px" runat="server" ShowBorder="false" ShowGridHeader="true" ShowHeader="false" AllowColumnLocking="True"> <Columns> <f:TemplateField Width="60px" HeaderText="序号"> <ItemTemplate> <asp:Label runat="server" Text=‘<%# Container.DataItemIndex + 1 %>‘></asp:Label> </ItemTemplate> </f:TemplateField> <f:BoundField runat="server" HeaderText="身高" DataField="ShenGao" /> <f:BoundField runat="server" HeaderText="体重" DataField="TiZhong" /> <f:BoundField runat="server" HeaderText="血压低" DataField="XueYaDi" /> <f:BoundField runat="server" HeaderText="血压高" DataField="XueYaGao" /> </Columns> </f:Grid> </Items> </f:Panel>
F.ready(function () { F(‘<% =Grid2.ClientID%>‘).autoWidth = true; F(‘<% =Grid2.ClientID%>‘).autoHeight = true; F(‘<% =Grid2.ClientID %>‘).setWidth(F(‘<% =Grid1.ClientID %>‘).getWidth() - 100); });
function showgirdItme(rowid) { //选择行隐藏列的ID,rowid来自后台 var itemid = $(‘#‘ + rowid).find(‘div .expander‘).attr(‘id‘); //复制的HTML $(‘#‘ + itemid).html($(‘#<% =PanelGrid1.ClientID %>-innerCt‘).html()); }
F(‘<% =Grid1.ClientID%>‘).view.on(‘collapsebody‘, function (rowNode, record, expandRow, eOpts) { var itemid = $(‘#‘ + rowNode.id).find(‘div .expander‘).attr(‘id‘); $(‘#‘ + itemid).html(‘‘); });
if (e.EventArgument.IndexOf("GridItem_") >= 0) { string rowid = e.EventArgument.Split(‘_‘)[1].ToString(); string id = e.EventArgument.Split(‘_‘)[2].ToString(); DataTable table = GetDataTable(); DataRow[] drs = table.Select("Id = ‘" + id + "‘"); DataTable dt = new DataTable(); dt = table.Clone(); foreach (DataRow dr in drs) { //模拟数据 dt.Rows.Add(dr.ItemArray); dt.Rows.Add(dr.ItemArray); if (Convert.ToInt32(id)>102) { dt.Rows.Add(dr.ItemArray); dt.Rows.Add(dr.ItemArray); } } //绑定 Grid2.DataSource = dt; Grid2.DataBind(); //注意延迟方法 string sc = "window.setTimeout(function () {showgirdItme(‘" + rowid + "‘);},100);"; FineUI.PageContext.RegisterStartupScript(sc); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。