0

제목에서 알 수 있듯이 MVC 응용 프로그램 내에서보기에서 검도 UI 그리드를 사용하고 있습니다.검도의 셀 클릭시 행 인덱스 및 열 머리글 필요 MVC 용

이제 특정 셀을 클릭 할 때 응용 프로그램에서 .cs 파일로 작성된 함수에 행 인덱스와 열 머리글 (해당 셀이 속한)을 전달해야합니다.

도움을 주시면 감사하겠습니다.

감사합니다 :)

P.S은 : 당신은 내가 충분한 정보를 제공하고 있지 않다라고 생각하면 내가 초보자 프로그래머 오전부터 알려 주시기 바랍니다!

+0

제공 한 정보만으로 충분하지만 사용자가 시도한 정보를 공유하지 않았습니다. –

+0

답장을 보내 주셔서 감사합니다, Jayesh,하지만 그게 어디서부터 시작해야할지 몰랐습니다. 나는 당신의 코드를 이해하려고 시도하고 그것을 달성하고자 시도한다. 질문이 있으시면 여기에 게시하겠습니다. 그 확인은? – J09

답변

0

참고로 ondatabound 이벤트를 사용하면 아래 코드를 확인할 수 있습니다.

function onDataBound(e) { 
      var grid = $("#grid").data("kendoGrid"); 
      $(grid.tbody).on("click", "td", function (e) { 
       var row = $(this).closest("tr"); 
       var rowIdx = $("tr", grid.tbody).index(row); 
       var colname = grid.columns[$("td", row).index(this)].title; 
       alert('row index is :- ' + rowIdx + ' and column name is:- ' + colname); 
      }); 
     } 

전체 코드 : -

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>jayesh Goyani</title> 

    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.common.min.css"> 
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.rtl.min.css"> 
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.default.min.css"> 
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.mobile.all.min.css"> 

    <script src="http://code.jquery.com/jquery-1.12.3.min.js"></script> 
    <script src="http://kendo.cdn.telerik.com/2016.2.714/js/angular.min.js"></script> 
    <script src="http://kendo.cdn.telerik.com/2016.2.714/js/jszip.min.js"></script> 
    <script src="http://kendo.cdn.telerik.com/2016.2.714/js/kendo.all.min.js"></script> 
</head> 
<body> 
    <div id="grid"></div> 
    <script> 
     $(document).ready(function() { 

      var products = [{ 
       ProductID: 1, 
       ProductName: "Chai", 
       SupplierID: 1, 
       CategoryID: 1, 
       QuantityPerUnit: "10 boxes x 20 bags", 
       UnitPrice: 18.0000, 
       UnitsInStock: 39, 
       UnitsOnOrder: 0, 
       ReorderLevel: 10, 
       Discontinued: false, 
       Category: { 
        CategoryID: 1, 
        CategoryName: "Beverages", 
        Description: "Soft drinks, coffees, teas, beers, and ales" 
       } 
      }, { 
       ProductID: 2, 
       ProductName: "Chang", 
       SupplierID: 1, 
       CategoryID: 1, 
       QuantityPerUnit: "24 - 12 oz bottles", 
       UnitPrice: 19.0000, 
       UnitsInStock: 17, 
       UnitsOnOrder: 40, 
       ReorderLevel: 25, 
       Discontinued: false, 
       Category: { 
        CategoryID: 1, 
        CategoryName: "Beverages", 
        Description: "Soft drinks, coffees, teas, beers, and ales" 
       } 
      }, { 
       ProductID: 3, 
       ProductName: "Aniseed Syrup", 
       SupplierID: 1, 
       CategoryID: 2, 
       QuantityPerUnit: "12 - 550 ml bottles", 
       UnitPrice: 10.0000, 
       UnitsInStock: 13, 
       UnitsOnOrder: 70, 
       ReorderLevel: 25, 
       Discontinued: false, 
       Category: { 
        CategoryID: 2, 
        CategoryName: "Condiments", 
        Description: "Sweet and savory sauces, relishes, spreads, and seasonings" 
       } 
      }, { 
       ProductID: 4, 
       ProductName: "Chef Anton's Cajun Seasoning", 
       SupplierID: 2, 
       CategoryID: 2, 
       QuantityPerUnit: "48 - 6 oz jars", 
       UnitPrice: 22.0000, 
       UnitsInStock: 53, 
       UnitsOnOrder: 0, 
       ReorderLevel: 0, 
       Discontinued: false, 
       Category: { 
        CategoryID: 2, 
        CategoryName: "Condiments", 
        Description: "Sweet and savory sauces, relishes, spreads, and seasonings" 
       } 
      }, { 
       ProductID: 5, 
       ProductName: "Chef Anton's Gumbo Mix", 
       SupplierID: 2, 
       CategoryID: 2, 
       QuantityPerUnit: "36 boxes", 
       UnitPrice: 21.3500, 
       UnitsInStock: 0, 
       UnitsOnOrder: 0, 
       ReorderLevel: 0, 
       Discontinued: true, 
       Category: { 
        CategoryID: 2, 
        CategoryName: "Condiments", 
        Description: "Sweet and savory sauces, relishes, spreads, and seasonings" 
       } 
      }]; 

      $("#grid").kendoGrid({ 
       dataSource: { 
        data: products, 
        schema: { 
         model: { 
          id: "ProductID", 
          fields: { 
           ProductID: { type: 'number' }, 
           UnitsInStock: { type: 'number' }, 
           ProductName: { type: 'string' }, 
           QuantityPerUnit: { type: 'string' }, 
           UnitPrice: { type: 'number' }, 
          } 
         } 
        }, 
       }, 
       dataBound: onDataBound, 
       columns: [ 
        { field: "ProductName", title: "ProductName" }, 
        { field: "UnitsInStock", title: "UnitsInStock" }, 
        { field: "QuantityPerUnit", title: "QuantityPerUnit" }, 
        { field: "UnitPrice", title: "UnitPrice" }, 
       ] 
      }); 
     }); 

     function onDataBound(e) { 
      var grid = $("#grid").data("kendoGrid"); 
      $(grid.tbody).on("click", "td", function (e) { 
       var row = $(this).closest("tr"); 
       var rowIdx = $("tr", grid.tbody).index(row); 
       var colname = grid.columns[$("td", row).index(this)].title; 
       alert('row index is :- ' + rowIdx + ' and column name is:- ' + colname); 
      }); 
     } 
    </script> 

</body> 
</html> 

나에게 어떤 관심 있다면 알려주십시오.