我試圖創建一個使用ASP.NET MVC 2這說明了兩點頁:Telerik的電網與阿賈克斯
1. the upper half of the page should show a form
2. the lower half should show the results based on the information from the form
我試着用Ajax.BeginForm做和更新的下半部分頁面使用UpdateTargetId。基本上,這工作。但是,結果還包含可分頁的Telerik網格。這是麻煩開始的地方。
網格主要顯示得很好,但當我嘗試瀏覽網格頁面時,它開始出錯。普通(非Ajax)網格使用鏈接。如果我使用網格的這種變體,我會陷入麻煩,因爲鏈接請求一個新頁面,該頁面不包含任何來自窗體的信息,因此我得到一堆錯誤。
如果我打開Ajax,它不起作用,因爲它不適用於通過Ajax檢索的部分視圖(腳本標記在這種情況下不起作用)。在這種情況下,我只是得到一個呈現爲純文本的JSON結果對象。
如果我把它放在一個頁面上,我也可以使它工作。但出於某種原因,網格不會使用Ajax。在索引視圖我用下面的代碼來呈現網格:
Html.Telerik().Grid<FoobarListItem>()
.Name("Foobar")
.DataBinding(dataBinding => dataBinding.Ajax().Select("_Paging", "Foobar"))
.ToolBar(commands => commands
.Custom()
.HtmlAttributes(new { id = "export", onclick = onclickValue })
.Text(Html.Alias("default", "ExportCSV"))
.Url("#")
)
.Columns(columns =>
{
//Template column which shows an action link
columns.Bound(o => o.Datum);
columns.Bound(o => o.VerbruikLaag);
columns.Bound(o => o.VerbruikNormaal);
columns.Bound(o => o.VerbruikPiek);
})
.Scrollable(scrolling => scrolling.Height(200).Enabled(false))
.Pageable()
.Localizable("nl-NL")
.Render();
}
但我是否把Ajax的數據綁定或沒有,它仍然呈現以同樣的方式表。有沒有人有一個想法,我要去哪裏錯了?
我讀到了,但代碼不適合我。 – Pieter 2011-01-27 07:43:11