我有一個Telerik電網的問題,我似乎無法在任何地方找到確切的問題。我正在從他們的網站演示客戶端編輯模板。當進入編輯模式,它會立即模說select
方法是從這個不確定的js語句:Telerik網格不渲染列中的dropdownlist MVC3
<script type="text/javascript">
function onEdit(e) {
$(e.form).find('#PageList').data('tDropDownList').select(function (dataItem) {
return dataItem.Text == e.dataItem['PageName'];
});
}
</script>
這是我的觀點:
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="Community_Portal_Admin" %>
<div class="gridFrame">
<% Html.Telerik().Grid(Of IndustryPageContent)() _
.Name("IndustryPageContent") _
.DataKeys(Function(k) k.Add(Function(d) d.ID)) _
.DataBinding(Function(db) db.Ajax() _
.Select("_GetPageContent", "Industry") _
.Update("_SetPageContent", "Industry")) _
.Columns(Function(c) c.Bound(Function(d) d.IndustryID)) _
.Columns(Function(c) c.Bound(Function(d) d.PageID)) _
.Columns(Function(c) c.Bound(Function(d) d.PageActionID)) _
.Columns(Function(c) c.Bound(Function(d) d.Content1)) _
.Columns(Function(c) c.Bound(Function(d) d.Content2)) _
.Columns(Function(c) c.Bound(Function(d) d.Content3)) _
.Columns(Function(c) c.Bound(Function(d) d.Content4)) _
.Columns(Function(c) c.Bound(Function(d) d.Content5)) _
.Columns(Function(c) c.Command(Function(d) d.Edit().ButtonType(GridButtonType.Image)).Width(60)) _
.Columns(Function(c) c.Bound(Function(d) d.ID).Hidden()) _
.ClientEvents(Function(e) e.OnEdit("onEdit")) _
.Editable(Function(c) c.Mode(GridEditMode.InForm).Enabled(True)) _
.Scrollable(Function(s) s.Height("350px")) _
.Pageable() _
.Selectable() _
.Render()
%>
<br />
<%: Html.ActionLink("Close", "Index", "Configuration", Nothing, New With {.class = "t-button", .Style = "font-size:12px;"})%>
</div>
<script type="text/javascript">
function onEdit(e) {
$(e.form).find('#PageList').data('tDropDownList').select(function (dataItem) {
return dataItem.Text == e.dataItem['PageName'];
});
}
</script>
這裏是我的控制器操作:
Function GetPageContent() As ActionResult
Try
ViewData("PageList") = SharedListDataRepository.PageList()
Return PartialView()
Catch ex As Exception
Throw
End Try
End Function
這裏是我的助手加載列表數據:
Public Shared Function PageList() As IEnumerable(Of ApplicationPage)
Dim l As IEnumerable(Of ApplicationPage)
Try
l = (From d In New AdminIndustrySetupDataContext(TripleDESSecurity.Decrypt(SharedData.PortalCnx)).AdminApplicationPages Order By d.ID Select New ApplicationPage With {
.ID = d.ID,
.PageName = d.PageName
}).AsEnumerable
Return l
Catch ex As Exception
Throw
Finally
If Not l Is Nothing Then
l = Nothing
End If
End Try
End Function
這是我的模型:你可以看到它的裝飾是UIHint
,它應該將控件帶入視圖,但是因爲錯誤是一個「未定義」元素的js錯誤,它告訴我列表控件從不使其進入頁面。這螢火蟲在HTML
Imports System.ComponentModel.DataAnnotations
Imports System.Runtime.Serialization
<KnownType(GetType(IndustryPageContent))> _
Public Class IndustryPageContent
<ScaffoldColumn(False)> _
Public Property ID As Integer = 0
Public Property IndustryID As Integer = 0
<UIHint("PageList"), Required()> _
Public Property PageID As Integer = 0
Public Property PageActionID As Integer = 0
Public Property Content1 As String = String.Empty
Public Property Content2 As String = String.Empty
Public Property Content3 As String = String.Empty
Public Property Content4 As String = String.Empty
Public Property Content5 As String = String.Empty
Public Sub New()
MyBase.New()
End Sub
End Class
並且最後在這裏與贊同,它只是不會有我的列表控件:
<%@ Control Language="vb" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.Telerik().DropDownList() _
.Name("PageList") _
.BindTo(New SelectList(CType(ViewData("PageList"), IEnumerable), "ID", "PageName"))
%>
所以我的猜測是,對於選擇方法的JavaScript將失敗,因爲UIHint
ISN」 t綁定控件權限,因此控件不在那裏調用select方法。
我錯過了什麼? Telerik網格是否有成功的Ajax綁定實現 - 使用VB.NET和aspx編輯,而不是剃鬚刀?或者,我是唯一一個在角落裏塗上了我必須與之合作的限制嗎?
我只有使用Telerik演示的問題,他們一直不完整和/或使用方法的矛盾,最終支持說:「哦,你做不到這一點時,真的嗎?那麼爲什麼是它在演示??
編輯
這是我最後的電網代碼,得到它的工作:
<% Html.Telerik().Grid(Of IndustryPageContent)() _
.Name("IndustryPageContent") _
.DataKeys(Function(k) k.Add(Function(d) d.ID)) _
.DataBinding(Function(db) db.Ajax() _
.Select("_GetPageContent", "Industry") _
.Update("_SetPageContent", "Industry")) _
.Columns(Function(c) c.Bound(Function(d) d.IndustryID)) _
.Columns(Function(c) c.Bound(Function(d) d.PageID)) _
.Columns(Function(c) c.Bound(Function(d) d.PageActionID)) _
.Columns(Function(c) c.Bound(Function(d) d.Content1)) _
.Columns(Function(c) c.Bound(Function(d) d.Content2)) _
.Columns(Function(c) c.Bound(Function(d) d.Content3)) _
.Columns(Function(c) c.Bound(Function(d) d.Content4)) _
.Columns(Function(c) c.Bound(Function(d) d.Content5)) _
.Columns(Function(c) c.Command(Function(d) d.Edit().ButtonType(GridButtonType.Image)).Width(60)) _
.Columns(Function(c) c.Bound(Function(d) d.ID).Hidden()) _
.Editable(Function(c) c.Mode(GridEditMode.InForm).Enabled(True)) _
.Scrollable(Function(s) s.Height("350px")) _
.Pageable() _
.Selectable() _
.Render()
%>
的ClientEvents
線不需要JS「名稱」。 PROPERT下拉列表中的y必須與它將作爲列表的屬性的名稱匹配。在這種情況下,PageID
和PageActionID
。這是我定義的工作的2個DDL的代碼:
<%@ Control Language="vb" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.Telerik().DropDownList() _
.Name("PageID") _
.BindTo(New SelectList(CType(ViewData("PageList"), IEnumerable), "ID", "PageIDandName")) _
.Render()
%>
<%@ Control Language="vb" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.Telerik().DropDownList() _
.Name("PageActionID") _
.BindTo(New SelectList(CType(ViewData("PageActionList"), IEnumerable), "PageActionID", "PageActionIDandAction")) _
.Render()
%>
我在這裏粘貼了錯誤的代碼,我實際使用的代碼在上面編輯的問題中。我在離開工作之前檢查了你在星期五建議的項目,但注意到它是一個完全不同的如何在網格中實現下拉列表編輯的實現。爲什麼示例中沒有發佈示例,因爲它應該是? –
我們的在線示例在瀏覽時是否工作?新項目是一個簡化版本,我們將使在線演示看起來一樣。 –
Atanas,你建議看看的項目使事情變得更加困難,因爲它使用強類型的下拉列表來打破我的模型。我不能改變這一點,這就是爲什麼我選擇了客戶端行編輯演示和示例,一旦我添加了渲染方法,我可以看到下拉菜單,但它實際上沒有根據我的選擇做任何更新。我將再次壓縮我的項目並通過支持票發送 –