2012-07-19 3 views
0

ASP 데이터 격자의 html 형식에 행을 추가하려고합니다. 내 표는 페이징을 가지고 있으며 html 형식의 행으로도 변환됩니다. 그래서 실제 레코드가있는 행에 클래스를 추가했습니다. 이제 html 테이블 행을 그리드에 추가해야합니다. 이 기록의 끝에 추가해야합니다. 누군가 이것을하는 방법을 알고 있습니까?특정 클래스가있는 행의 마지막을 향해 테이블 ​​행을 추가하는 방법은 무엇입니까?

테이블 구조 :

<table> 
    <th> 
    </th> 
    <tbody> 
     <tr class="clientData">1</tr> 
     <tr class="clientData">2</tr> 
     <tr class="clientData">3</tr> 
     <tr>Exclude This Row</tr> 
     <tr>Exclude This Row</tr> 
    </tbody> 
</table> 

스크립트 :

{ $("#ctl00_Content_GrdCustomer tbody").append(selCustomersRow); } // 

답변

1

뭔가

$('#ctl00_Content_GrdCustomer tbody tr.clientData').last().after(selCustomersRow); 

처럼 또는 천사의 코멘트처럼, 직접 마지막 tr.clientData을 선택

$('#ctl00_Content_GrdCustomer tbody tr.clientData:last').after(selCustomersRow); 

http://api.jquery.com/after/

+0

모두에게 감사 ... 이것은 나를 위해 일했다 :) – NewBie

+1

이것은 더 좋을지도 모른다 : $ ('# ctl00_Content_GrdCustomer tbody tr.clientData : last'). after (selCustomersRow); – Angel

-1

은 시도 ...

{ $("#ctl00_Content_GrdCustomer tbody tr").last().append(selCustomersRow); } 
+0

-1의 원인을 말해 !!!!! –

+0

나는 downvoter 아니지만, 위의 코드는 마지막 TR에 중첩 된 TR을 의미하는 행을 추가합니다. – Gavin

+0

그리고 그가 필요로하는 것. –

0

더 좋은 방법은 올바른 테이블 태그를 사용하는 것입니다.

<table> 
    <thead> 
     <tr> 
      <td>Column header 1</td> 
      <td>Column header 2</td> 
      <td>Column header 3</td> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td>Column 1</td> 
      <td>Column 2</td> 
      <td>Column 3</td> 
     </tr> 
     <tr> 
      <td>Column 1</td> 
      <td>Column 2</td> 
      <td>Column 3</td> 
     </tr> 
    </tbody> 
    <tfoot> 
     <tr> 
      <td>Column footer 1</td> 
      <td>Column footer 2</td> 
      <td>Column footer 3</td> 
     </tr> 
    </tfoot> 
</table> 

당신은 헤더가 필요하지 않을 수 있습니다,하지만 당신은 TBODY과 TFOOT 내에 매김 내에서 "기록"을 모두 충실 할 수 있습니다. 최종 TBODY에 행을 추가하지만, TFOOT 내 매김하기 전에 것입니다 당신이

$("#ctl00_Content_GrdCustomer tbody").append(selCustomersRow); 

사용할 수 있습니다

이 방법.

+0

완벽하게 맞았지 만, 누군가가 자신의 데이터 그리드를 렌더링하는 방법을 ASP에 말할 수 있는지 의심 스럽다. – Johnny5

+0

IIRC에서 GridView 컨트롤은 thead에 열을 추가하고 tbody에 페이지 매김을 적용하여 실제 데이터를 tbody 요소에 남겨 둡니다. – Gavin

관련 문제