2013-03-03 2 views
0

격자가 있습니다.onRowSelect : 셀 인덱스를 얻는 방법

@(Html.Telerik().Grid(Model) 
     .Name("Grid") 
     .Columns(columns => 
     { 
      //columns & bound 
     }) 
     .ClientEvents(e=> e.OnRowSelect("OnRowSelect")) 

행을 클릭하면 cellindex (클릭 한 사용자)를 알아야합니다.

function onRowSelect(e){}

가 어떻게 거기에서 추출 않습니다
나는 기능이?

답변

0

RowSelect 이벤트를 통해 열 인덱스를 검색 할 수 없습니다.

나는 그리드 (onLoad 이벤트를 통해) 초기화되면이 같은 자신의 대리인 이벤트를 첨부 제안 :

function onGridLoad(){ 
    $(this).data().tGrid.$tbody.on('click','td',function(e){ 
     alert('COLUMN INDEX: '+$(this).index()) 
    }) 
} 
+0

JQuery와 태그가 없습니다. –

0

내 대답은 Table row and column number in jQuery에,이 질문에 신용을 기반으로합니다.

자바 스크립트 :

이 다음 시도

<script> 
    function OnDataBound() { 
     // #Grid needs to match the name of the grid in View's markup. 
     $('#Grid table td').click(function() { 
      var col = $(this).parent().children().index($(this)); 
      var row = $(this).parent().parent().children().index($(this).parent()); 
      alert('Row: ' + row + ', Column: ' + col); 
     }); 


     //As a side note, you can get at the contents of the row selected with 
     //something along these lines: 
     //(this will not work unless you substitute the "EmployeeId" id with a valid one from your model. 
     $('#Grid table tr').dblclick(function() { 
      alert($(this).find("span[id=EmployeeId]")[0].innerText); //EmployeeId is just a column name used for example purposes. 
     }); 
    } 



</script> 

그리드 마크 업 :

@(Html.Telerik().Grid(Model) 
    .Name("Grid") 
    .Columns(columns => 
    { 
     //columns & bound 
    }) 
    .ClientEvents(e=> e.OnDataBound("OnDataBound")) // This changed to a OnDataBound event. 
+0

@Refael - 찾고 있던 기능을 구현 했습니까? – Igorrious

관련 문제