2017-08-08 48 views
0

我想实现移动面板里面正好旁边命令按钮点击一个HTML表中的行,像这样不同的元素另一TR下:将现有元素到一个新的TR使用JQuery

jQuery("[id*=lnkButton]").click(function() { 
    $(this).closest('tr').after("<tr class ='alt'><td> appendTo here </td></tr>"); 
    //$("#source").appendTo("#destination"); how to run this line inside TD and make the panel visible in there upon inserted 
} 

这就是我想要移动到新创建的行面板:

<asp:Panel ID='panelPhotos' runat='server' Visible="False"> a lot of elements</Panel> 

面板包含如下链接:点击事件按钮服务器控件...

氏s是表(GridView控件):

<asp:GridView ID="gridScopeItem" runat="server" AllowPaging="True"  DataKeyNames="ItemID" AutoGenerateColumns="False" OnPageIndexChanging="gridScopeItem_PageIndexChanging" OnRowCommand="gridScopeItem_RowCommand" OnSelectedIndexChanged="gridScopeItem_SelectedIndexChanged" 
    PageSize="10" Caption="Scope Items" ClientIDMode="Static"> 
<Columns> 
    <asp:BoundField DataField="ItemID" HeaderText="Item ID"/> 
    <asp:BoundField DataField="Cat" HeaderText="CAT" ReadOnly="true"/> 
    <asp:BoundField DataField="Sel" HeaderText="SEL" ReadOnly="true"/> 
    <asp:BoundField DataField="Activity" HeaderText="ACT" ReadOnly="true"/> 
    <asp:BoundField DataField="SpecDetailedDescription" ReadOnly="true" HeaderText="Description" /> 
    <asp:TemplateField> 
     <ItemTemplate> 
      <asp:LinkButton runat="server" ID="Link1" CommandName="detail" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" Text="<img src='img/upload.png' title= 'Upload Pictures' style='max-height: 20px; max-width: 30px;' />" /> 
     </ItemTemplate> 
    </asp:TemplateField>       
</Columns> 

所以,当我点击该LinkBut​​ton的我需要添加新的TR/TD与现有面板(panelPhotos)内。

+0

你可能想发布一些HTML而不是ASP.NET。 – MortenMoulder

回答

0

https://jsfiddle.net/q8vof2fa/

$("body").on("click", "td", function() { 
    $(this).closest("tr").after("<tr><td> appendTo here </td><tr>"); 
}); 

像这样的事情?单击一个<td>元素,并在其父项后追加一个<tr>元素。

+0

不,实际上我可以添加新的tr和td,我需要的是在刚刚创建的td内添加现有面板(此操作应该在LinkBut​​ton的事件点击中执行)。 – Poyson1

相关问题