2013-03-25 69 views
0

我想調用Telerik()。Grid中的Ajax函數。如何在Telerik()中調用JavaScript函數。點擊Grid按鈕?

這是我Telerik的()。網格

@(Html.Telerik().Grid(Model) 
     .Name("SiteGrid") 
     .Columns(columns => 
     { 
      columns.Bound(o => o.PKComID).Width(50); 
      columns.Bound(o => o.CompanyName).Width(50);  
//In here I want to add a button and call the Ajax function when click the button 
     })  

      .Pageable(paging => paging.PageSize(15).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom)) 
       .Sortable() 
    ) 

這是我的Java腳本函數

<script type="text/javascript"> 

    function getCompanyDetails(companyID) { 

     $.ajax({ 

      type: 'POST', 
      dataType: 'html', 
      url: '@Url.Action("CompanybyID", "Search")', 
      data: ({ ComID: companyID }), 
      success: function (data) { 
       //alert(data); 
       $('#companyDetails').html(data); 


      }, 
      error: function (xhr, ajaxOptions, thrownError) { 
       alert(xhr.status); 
       alert(thrownError); 
      } 
     }); 

    } 
    </script> 

我如何可以調用側getCompanyDetails()功能網格視圖?

回答

0
@(Html.Telerik().Grid(Model) 
     .Name("SiteGrid") 
     .Columns(columns => 
     { 
      columns.Bound(o => o.PKComID).Width(50); 
      columns.Bound(o => o.CompanyName).Width(50);  
     })  
      .ClientEvents(events => events.OnComplete("getCompanyDetails")) 
      .Pageable(paging => paging.PageSize(15).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom)) 
       .Sortable() 
    ) 

正式例如:http://demos.telerik.com/aspnet-mvc/razor/grid/customcolumncommand

相關問題