2014-07-08 84 views
1

我有一個Kendo網格,我試圖在選擇一行後測試javascript函數調用。Kendo grid - 調用javascript函數時出錯:「javascript運行時錯誤:'funcName'未定義」

<div id="datagrid"> 
    @(Html.Kendo().Grid(Model) 
     .Name("datagrid_Concessoes") 
     .Columns(columns => 
     { 
      columns.Bound(c => c.Id).Width(70); 
      columns.Bound(c => c.Code).Title("Código"); 
      columns.Bound(c => c.Description).Title("Descrição"); 
      columns.Bound(c => c.CreationDate).Title("Data de Criação"); 
      columns.Bound(c => c.CreationUser).Title("Criado por"); 
     }) 
     .HtmlAttributes(new { style = "height: 534px;" }) 
     .Scrollable() 
     .Sortable() 
     .Selectable() 
     .Events(e => e.Change("test")) 
     .Pageable(pageable => pageable 
      .Refresh(true) 
      .ButtonCount(5)) 
     .DataSource(dataSource => dataSource 
      .Ajax() 
      .PageSize(15) 
      .Read(read => read.Action("GetConcessoes", "MasterData")) 
     ) 
    ) 
</div> 

和JavaScript:

function test() { 
    alert("test"); 
} 

我得到一個javascript runtime error: 'test' is undefined只要電網即將被顯示。我試過行:

.Events(e => e.Change("test")) 
.Events(e => e.Change("test()")) 

,但沒有運氣

+0

您正在使用哪個版本的kendo ui和jqeury? –

+0

你可以嘗試在網格之前立即放置函數,看看會發生什麼?它可能只是該功能尚未定義 –

+0

@ mo.esmp,''kendoUi'版本是最新的,'jquery'是1.7.1 – chiapa

回答

2

網格可能是負載立即燒成Change事件,如果您的Java腳本函數都在頁面的底部限定他們可能不可用。

解決方法是將text()函數向上移動到此網格上方以確保其已定義。

1

這很奇怪,但根據telerik論壇(Grid row selection change event not firing)中的錯誤報告,它在jQuery版本1.7.2中正常工作。嘗試版本1.7.2,看看它的工作與否。

+0

+1爲更新的jQuery版本的鏈接和建議 – chiapa

相關問題