は、私はそれがAJAXのために働いてい:.NET AJAXをMVC /ラーニングに変換する - MVCパラダイムを破ることなくこの機能を実現することは可能ですか?私はMVCで以下の機能を複製しようとしています
- ユーザーページ上にアイテムをドラッグ・アンド・ドロップします。
- OnDropped新しいコントロールが作成され、ページに添付されます。コントロールはRadDock型で、RadDockZone型のコントロールにドッキングされます。
旧コード:
今/// <summary>
/// Creates the RadDock + Contents when dropping a graph onto the page.
/// </summary>
/// <param name="sender"> The RadListBox with an element being dropped from inside it. </param>
/// <param name="e"> Information about the drop such as target and what is being dropped. </param>
protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
{
CormantRadDockZone dockZone = RadDockLayout1.RegisteredZones.OfType<CormantRadDockZone>().First(registeredDockZone => registeredDockZone.ID == e.HtmlElementID);
if (!object.Equals(dockZone, null) && !dockZone.Docks.Any())
{
RadSlidingPane slidingPane = ((sender as RadListBox).Parent as RadSlidingPane);
CormantReport report = new CormantReport(int.Parse(e.SourceDragItems[0].Value), e.SourceDragItems[0].Text, slidingPane.Title);
CormantRadDock dock = new CormantRadDock(report);
dock.CreateContent();
dock.Dock(dockZone);
}
}
、私はMVCでこのような何かを行う方法のまわりで私の頭をラップしようとしています。私が考えているのは、ビューが必要なデータを取得し、そのデータをコントローラに戻す必要があるということです。コントローラは、RadDockの作成、オブジェクトのtoJSONを処理し、データをビューに戻します。そのデータを取得した後、私はRadDockZoneに追加できるように要素を再作成できるはずですが、Telerik.Web.UI.RadDock()コンストラクタを使用しないと、要素が再現できないはずです? これは可能ですか?
function OnClientDropped(sender, eventArgs) {
//Capture e.HTMLElementID, e.SourceDragItems[0].Value, e.SourceDragItems[0].Text, and slidingPane.Title here
var droppedID = eventArgs.get_htmlElement().id;
if(droppedID.indexOf("RadDockZone") != -1)
{
var radDockZone = $find(droppedID);
//This constructor does not exist!
var radDock = new Telerik.Web.UI.RadDock();
radDock.dock(radDockZone);
}
else
{
alert("Failed to find RadDockZone on dropped target.");
}
var slidingPaneTitle = "";
if (sender.get_id().indexOf("lstBxHistorical") != -1) {
slidingPaneTitle = "Historical Widgets";
}
else if (sender.get_id().indexOf("lstBxCustom") != -1) {
slidingPaneTitle = "Custom Widgets";
}
else {
alert(sender.get_id());
}
$.ajax({
type: 'POST',
url: 'ReportDropped',
dataType: 'json',
data: {
//e.HTMLElementID, e.SourceDragItems[0].Value, etc...
},
success: function (data) {
alert("Success");
},
errror: function (xhr, ajaxOptions, error) {
alert("Error");
}
});
}
http://www.telerik.com/help/aspnet-ajax/mvc-radcontrols-for-aspnet-mvc-overview.html RADControls for AJAXは、ASP.NET MVCアプリケーションへの統合をサポートしています...ちょうど、時々、少しの愛で、私は思います!前にこれをした人を見つけることを願っています。 :) –