2013-09-30 61 views
0

我使用Kendo UI Grid將動作鏈接插入到客戶端模板列中。此操作鏈接調用數據編輯視圖。見例如:Kendo UI Ajax請求

c.Bound(p => p.sID).ClientTemplate(@Html.ImageActionLink(Url.Content("~/Content/images/edit3.png"), "Edit", "Edit", new { id = "#= sID #" }, new { title = "Edit", id = "Edit", border = 0, hspace = 2 }).ToString() 
          ).Title("").Width(70).Filterable(false).Groupable(false).Sortable(false); 

我的問題是如何配置網格以顯示操作鏈接被點擊時一個ajax裝載機,直到編輯視圖渲染?

回答

0

您可以創建相對股利和插入有您的網格和裝載機的包裝:

<div class="grid-wrapper"> 
    <div class="loading-wrapper"> 
     <div class='k-loading-image loading'></div> 
     <!-- k-loading-image is standart kendo class that show loading image --> 
    </div> 
    @(Html.Kendo().Grid()....) 
</div> 

CSS:

.grid-wrapper { 
    position: relative; 
} 
.loading-wrapper { 
    display: none; 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    z-index: 1000; 
} 
.loading { 
    position: absolute; 
    height: 4em; 
    top: 50%; 
} 

添加到imageActionLink在htmlAttributes對象命名爲 「編輯」(例如)類,並寫入點擊事件處理程序:

$(document).on('click', '.edit', function (e) { 
    $('.loading-wrapper').show(); 
    $.ajax({ 
     // ajax opts  
     success: function(response) { 
      // insert your edit view received by ajax in right place 
      $('.loading-wrapper').hide(); 
     } 
    }) 
}); 
0

你可以這樣做:

c.Bound(p => p.sID).Template(@<a href=\"YourLink\@item.sID\">Edit</a>).Title("Edit").Encoded(false); 
//encoded false = Html.Raw