0
我有一個用於搜索的幾個控件的視圖。當用戶搜索(Ajax.BeginForm)時,我將數據返回到動態生成的PartialView(Telerik MVC3 Grid)中。Telerik MVC3 Razor Grid - 從控制器返回的部分視圖
這一切工作正常。在網格中有用於選擇一行的按鈕。當我選擇一行時,它發佈到我的控制器,我做一些「東西」等。當我嘗試回到視圖時,我得到的是我自己的網頁上的網格數據,它顯示爲一張沒有邊框的表格,沒有其他控制等。我的代碼如下。
我的部分網格:
@model Highlander.Areas.Highlander.Models.ViewModels.DeliveriesGridViewModel
@using System.Data;
@(Html.Telerik().Grid<System.Data.DataRow>(Model.Data.Rows.Cast<System.Data.DataRow>())
.Name("Grid")
.DataKeys(dataKeys => dataKeys.Add("DeliveryID"))
.Columns(columns =>
{
columns.Command(commandbutton =>
{
commandbutton.Select().ButtonType(GridButtonType.ImageAndText);
}).Width(80).Title(ViewBag.Title);
columns.LoadSettings(Model.Columns as IEnumerable<GridColumnSettings>);
})
.DataBinding(dataBinding => dataBinding.Server().Select("_MarkSystem", "Deliveries"))
.EnableCustomBinding(true)
.Resizable(resize => resize.Columns(true))
)
我的控制器:
[GridAction]
public ActionResult _MarkSystem(GridCommand command, int id)
{
string shipDeliver = DataCache.ShipDeliver;
DataTable fullTable = DataCache.FullTable;
// call to function to get the datatable data based on the id
rHelpers.GetDataTableRow(id, fullTable, shipDeliver);
// get the data for the grid into the model
fullTable = DataCache.FullTable;
model = new DeliveriesGridViewModel();
model.Data = fullTable;
model.Columns = rHelpers.NewColumns(DataCache.FullTable);
return PartialView("_DeliveryGrid", model);
//if (Request.IsAjaxRequest())
//{
// return PartialView("_DeliveryGrid", model);
//}
//return PartialView("_DeliveryGrid", model);
//return PartialView("DeliveryManager", model);
}
正如你可以看到我已經嘗試過各種東西,但沒有成功。
任何人都可以給我一些方向。
謝謝你的時間。
我嘗試了你的建議,我得到了相同的結果。我不確定我瞭解你給我的代碼背後的推理。我不想編輯數據。我發佈我選擇的數據行,對行中的數據進行一些計算,然後將其從網格中移除。 我只是不能讓它返回到我的視圖,並正確顯示整個頁面。它顯示的是我的網格,它看起來像一張沒有邊框的表格。 這是我的第一個MVC3應用程序,所以也許我只是不完全理解你在說什麼。 感謝您的時間,我會期待您的想法。 – Squeal