默认情况下,看起来Telerik Grid for MVC3只向我的控制器提交标记为“脏”的行。我需要能够将Telerik Grid上的所有行提交给我的控制器。换句话说,我认为我需要将所有行标记为已更改,以便网格将所有行发送到我的控制器。
我正在使用Ajax数据绑定,如下所示:
.DataBinding(dataBinding => dataBinding 阿贾克斯() .Select(“GetData”,“ModuleAccess”,new {roleId = @ ViewBag.RoleId,appId = @ ViewBag.AppId}) .Update(“SaveBatchEditing”,“ModuleAccess”)
答案 0 :(得分:0)
@(Html.Telerik().Grid<BarcodeListModel>()
.Name("orders-grid")
.ClientEvents(events => events.OnDataBinding("onDataBinding"))
.DataKeys(keys =>
{
keys.Add(x => x.Id);
})
.ToolBar(commands =>
{
commands.SubmitChanges();
})
.DataBinding(dataBinding =>
dataBinding.Ajax()
.Select("BulkEditSelect", "ProductVariant")
.Update("BulkEditSaveBarcode", "ProductVariant")
.Delete("DeleteBarcode", "ProductVariant")
)
.Columns(columns =>
{
columns.Bound(x => x.Id).ReadOnly();
columns.Bound(x => x.SKU);
columns.Bound(x => x.barcode);
//columns.Bound(x => x.Id)
// .Template(x => Html.ActionLink(T("Admin.Common.View").Text, "DeleteBarcode", new { id = x.Id }))
// .ClientTemplate("<a href=\"DeleteBarcode/<#= Id #>\">" + "Delete" + "</a>")
// .Width(50)
// .Centered()
// .HeaderTemplate("DeleteBarcode")
// .Filterable(false)
// .Title("Delete");
columns.Command(commands => commands.Delete()).Width(180);
})
.Pageable(settings => settings.PageSize(gridPageSize).Position(GridPagerPosition.Both))
.DataBinding(dataBinding => dataBinding.Ajax().Select("BarcodeList", "ProductVariant", Model))
.Editable(editing => editing.Mode(GridEditMode.InCell))
.EnableCustomBinding(true)
)
像这段代码一样使用
答案 1 :(得分:0)
我找到了答案:
function ModuleAccessGridHasChanges() {
var grid = $("#ModuleAccessGrid").data("tGrid");
if (grid != null) {
var additionalValues = grid.data;
if (!$.telerik.trigger(grid.element, 'submitChanges', { values: additionalValues })) {
grid.sendValues($.extend({}, additionalValues), 'updateUrl', 'submitChanges');
}
}
}
Fiddler显示网格的所有数据: