2012-05-22 39 views
1

jqgrid를 동적으로 생성 했으므로 버튼의 onclick 함수를 호출 할 수 없습니다.jqgrid 사용자 정의 포맷터 버튼 클릭 이벤트가 작동하지 않습니다.

내 코드 :

function buildButtons(cellvalue, options, rowObject) { 
      var optionsRowId = options.rowId; 
      var editDelButtons = "<input style=\"height:22px;width:40px;\" type=\"button\" value=\"Edit\" onclick=\"javascript:testRow('" + optionsRowId + "')\" />"; 
      return editDelButtons; 

     } 

function testRow(rowID) 
{ 
    alert(rowID); 
} 

}

내가있는 jqGrid의 각 행의 부톤 섬 클릭 할 때 항상 얻을 오류가

이 내 기능 기록 된 "기능이 정의되어 있지 않습니다"입니다 customFormatter 함수 바로 아래에.

미리 감사드립니다. 미리 감사드립니다.

+0

문제를 나타내는 더 큰 코드 예 (EG : jsfiddle)를 게시 할 수 있습니까? –

답변

2

testRow 기능을 .ready() 기능 밖으로 가져와야합니다.

$(function(){ 

    function buildButtons(cellvalue, options, rowObject) { 
     var optionsRowId = options.rowId; 
     var editDelButtons = "<input style=\"height:22px;width:40px;\" type=\"button\" value=\"Edit\" onclick=\"javascript:testRow('" + optionsRowId + "')\" />"; 

     return editDelButtons; 
    } 

}) 

function testRow(rowID) 
{ 
    alert(rowID); 
}