UltraWebGrid에서 선택한 로우 삭제하는 방법

2008.02.04 13:05 개발언어/3rd Part
HOWTO:How to delete rows on the client in UltraWebGrid?
참고를 하였다


In order to delete rows on the client in javascript you need to use the javascript function: igtbl_deleteRow(gridName,rowID). First, be sure to allow the deletion itself by setting the AllowDeleteDefault property in the DisplayLayout object or AllowDelete on the specific band.

The function needs to be passed the name of the grid and the ID of the row you want to delete.

The following sample Javascript code would delete all rows on the client in a function.

function delete()
    //make sure that deletes are allowed
    //get the first row in the grid
     var row=igtbl_getRowById("UltraWebGrid1r_0");
    //delete the first row in the grid
    //create a counter for the row id
     var cnt=0;
    //create a loop, if the row has a next sibling then we need to delete it
        //increment the counter for the next rowID
        //get the row current row using the name of the grid and the row number from our counter so we can check it for a sibling
        //finally delete that row,

All the selected rows within the grid can be deleted as well. For deleting selected rows, use the following function: igtbl_deleteSelRows(gridName).


이걸 참고하여서 선택한 로우만 삭제하게 바꾸었다.

우선 호출할 자바스크립트 버튼생성을 생성한다
<input type = "button" onclick ="SelectDeleteRow()" value ="선택한 ROW삭제" style="height: 32px" />

코드부분은 이렇게 작성하였다

 function SelectDeleteRow()
     var row = igtbl_getActiveRow("UltraWebGrid1").Element.id;  //현재 선택한 로우 id    
     igtbl_setActiveRow("UltraWebGrid1", igtbl_getElementById(igtbl_getActiveRow("UltraWebGrid1").Element.id) );
     igtbl_selectRow("UltraWebGrid1", row, true);      //also select the activerow in the grid

설명은 이렇다. 우선 ActiveRow를 선택하면 그 아이디를 받아서 setActiveRow로 세팅을 한다.
igtbl_deleteSelRows함수를 사용하여 선택한 로우를 삭제하면된다.

선택한 로우에 대한 색깔지정이나 이런건 생략하였다.