1对n再对n的grid设计
参考代码:
<script>
function radioChange()
{
var radioItem = document.getElementsByName("radioParent");
var objItem = document.getElementsByTagName("tr");
var len = objItem.length;
var checkID;
btnNew.disabled = false ;
// Hide All Childen Table
for(var i=0; i<len; i++)
{
if (objItem[i].id.indexOf("div") > -1 )
{
objItem[i].style.display = "none";
}
}
// Show Selected Childen Table
for(var i=0; i<radioItem.length; i++)
{
if (radioItem[i].checked)
{
radioID.value = radioItem[i].id;
var trobjItem = document.getElementById("div"+radioItem[i].id);
if (trobjItem.getElementsByTagName("input").length > 0)
{
trobjItem.style.display = "block";
trobjItem.getElementsByTagName("input")[0].click();
//HighShowParent(trobjItem.getElementsByTagName("input")[0]);
btnEdit.disabled = false ;
}
else
{
//HighShowParent(trobjItem.getElementsByTagName("input")[0]);
btnEdit.disabled = true ;
}
HighShowParent(radioItem[i]);
//btnSearch.focus();
//radioItem[i].focus();
return ;
}
}
}
</script>
<asp:GridView ID="grvGridView" runat="server" Width="1454px" AutoGenerateColumns="False"
AllowPaging="True" PagerSettings-Visible="False" AllowSorting="True" CellPadding="0"
CellSpacing="1" BorderWidth="0px" HeaderStyle-ForeColor="window" >
<HeaderStyle ForeColor="White" />
<EmptyDataRowStyle CssClass="EmptyDataRowStyle" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<input id='<%# Container.DataItem("ORDER_REQUEST_NO") %>|<%# Container.DataItem("DETAIL_NO") %>'
type="radio" name="radioParent" value='<%# Container.DataItem("ORDER_REQUEST_NO") %>|<%# Container.DataItem("DETAIL_NO") %>'
onclick="radioChange();" />
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:BoundField DataField="ORDER_DEPT_CODE" HeaderText="敪拲晹栧僐乕僪" SortExpression="ORDER_DEPT_CODE">
<HeaderStyle Width="125px" HorizontalAlign="Left" />
<ItemStyle Width="125px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="DEPT_SHORT_NAME" HeaderText="敪拲晹栧" SortExpression="DEPT_SHORT_NAME">
<ItemStyle Width="70px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="KBN_NAME" HeaderText="巇擖懳徾嬫暘" SortExpression="KBN_NAME">
<ItemStyle Width="107px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="PROJECT_NO" HeaderText="僾儘僕僃僋僩斣崋" SortExpression="PROJECT_NO">
<ItemStyle Width="130px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="ORDER_NO" HeaderText="拲暥斣崋" SortExpression="ORDER_NO">
<ItemStyle Width="120px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="COMPANY_NAME" HeaderText="儀儞僟乕" SortExpression="COMPANY_NAME">
<ItemStyle Width="230px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="STAFF_NAME" HeaderText="敪拲怽惪幰" SortExpression="STAFF_NAME">
<ItemStyle Width="90px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="EST_DATE" HeaderText="尒愊擔" DataFormatString="{0:d}" SortExpression="EST_DATE">
<ItemStyle Width="70px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="EST_FILE_NO" HeaderText="尒愊彂斣崋" SortExpression="EST_FILE_NO">
<ItemStyle Width="250px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="VENDOR_PAY" HeaderText="巟暐僒僀僩" SortExpression="VENDOR_PAY">
<ItemStyle Width="185px" HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:PlaceHolder ID="pnlChildView" runat="server"></td></tr>
<tr id='div<%# Container.DataItem("ORDER_REQUEST_NO") %>|<%# Container.DataItem("DETAIL_NO") %>'
style="display: none">
<td style="border-width: 0">
</td>
<td colspan="10" style="border-width: 0">
<asp:GridView ID="GridViewChildren" runat="server" AutoGenerateColumns="False" CellPadding="0"
CellSpacing="1" BorderWidth="0px" DataSource='<%# Container.DataItem.CreateChildView("ParentTable_ChildTable") %>'>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<input id='<%# Container.DataItem("ORDER_REQUEST_NO") %>|<%# Container.DataItem("DETAIL_NO") %><%# Container.DataItem("DEMAND_DATE") %>'
type="radio" name="<%# Container.DataItem("ORDER_REQUEST_NO") %>|<%# Container.DataItem("DETAIL_NO") %>" value='<%# Container.DataItem("DEMAND_DATE") %>'
/>
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:BoundField DataField="DEMAND_DATE" HeaderText="惪媮擔" DataFormatString="{0:d}"
NullDisplayText="">
<ItemStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="LAST_TAX" HeaderText="惪媮妟惻敳" NullDisplayText="" DataFormatString="{0:###,###,###,###,###,##0}"
HtmlEncode="false">
<ItemStyle Width="160" HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="TAX" HeaderText="徚旓惻妟" NullDisplayText="" DataFormatString="{0:###,###,###,###,###,##0}"
HtmlEncode="false">
<ItemStyle Width="160" HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="ADJUSTMENT" HeaderText="挷惍妟" NullDisplayText="" DataFormatString="{0:###,###,###,###,###,##0}"
HtmlEncode="false">
<ItemStyle Width="160" HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="TAX_INCLUDED" HeaderText="惪媮妟惻崬" NullDisplayText="" DataFormatString="{0:###,###,###,###,###,##0}"
HtmlEncode="false">
<ItemStyle Width="160" HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
<AlternatingRowStyle CssClass="tdEven" />
</asp:GridView>
</asp:PlaceHolder>
</ItemTemplate>
<HeaderStyle CssClass="none" />
<ItemStyle CssClass="none" />
<FooterStyle CssClass="none" />
</asp:TemplateField>
</Columns>
<AlternatingRowStyle CssClass="tdEven" />
<PagerSettings Visible="False" />
</asp:GridView>