我正在尝试使用一起过滤和编辑的ShieldUI数据网格。我在ASP.Net核心应用程序中使用。 有趣的是 - 我添加了编辑和删除按钮到行,它似乎最初工作。但是,当我尝试通过javascript函数更改过滤器值时,正确的过滤值出现在行中,但编辑和删除按钮消失,不再可用。我仍然可以使用顶部的插入按钮,但即使在那里我也无法保存新值,因为编辑/更新按钮不再可见。 有没有其他人有这个问题,可能知道解决这个问题的方法?
这是gridview-code:
@(Html.ShieldGrid()
.Name("actionsGrid")
.DataSource(ds => ds
.Events(eb => eb
.Error(@<text>
function (event) {
if (event.errorType == "transport") {
// transport error is an ajax error; event holds the xhr object
alert("transport error: " + event.error.statusText);
// reload the data source if the operation that failed was save
if (event.operation == "save") {
this.read();
}
}
else {
// other data source error - validation, etc
alert(event.errorType + " error: " + event.error);
}
}
</text>))
.Remote(rb => rb
.ReadConfiguration(r => r
.Add("type", "GET")
.Add("url", "/api/admin/tree/params")
.Add("dataType", "json"))
.ModifyObject(m => m
.Modify(ShieldUI.AspNetCore.Mvc.DataSource.ModifyOptions.Create, @<text>
function (items, success, error) {
var newItem = items[0];
newItem.data.actionid = $("#actionReference").html();
$.ajax({
type: "POST",
url: "/api/admin/tree/params",
dataType: "json",
contentType : "application/json; charset=utf-8",
data: JSON.stringify(newItem.data),
complete: function (xhr) {
if (xhr.readyState == 4) {
if (xhr.status == 201) {
var location = xhr.getResponseHeader("Location");
success();
return;
}
}
error(xhr);
}
});
}
</text>)
.Modify(ShieldUI.AspNetCore.Mvc.DataSource.ModifyOptions.Update, @<text>
function (items, success, error) {
$.ajax({
type: "PUT",
url: "/api/admin/BaseScenarioApi/tree/@Model.ScenarioId/params",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(items[0].data)
}).then(success, error);
}
</text>)
.Modify(ShieldUI.AspNetCore.Mvc.DataSource.ModifyOptions.Remove, @<text>
function (items, success, error) {
var actionid = items[0].data.actionId;
var paramname = items[0].data.paramName;
$.ajax({
type: "DELETE",
url: "/api/admin/BaseScenarioApi/tree"?paramName=" + paramname
}).then(success, error);
}
</text> )))
.FilterGroup(
ShieldUI.AspNetCore.Mvc.DataSource.FilterCondition.Or,
new object[]{
new Dictionary<string, string>(){
{"path", "actionId"},
{"filter", "eq"},
{"value", "dummy"}
},
new Dictionary<string, string>(){
{"path", "actionId"},
{"filter", "isnull"}
},
})
.Schema(sb => sb
.Fields("actionId", fb => fb.Path("actionId").Type(ShieldUI.AspNetCore.Mvc.DataSource.FieldType.String))
.Fields("orderNumber", fb => fb.Path("orderNumber").Type(ShieldUI.AspNetCore.Mvc.DataSource.FieldType.Number))
.Fields("isActive", fb => fb.Path("isActive").Type(ShieldUI.AspNetCore.Mvc.DataSource.FieldType.Boolean))
.Fields("paramType", fb => fb.Path("paramType").Type(ShieldUI.AspNetCore.Mvc.DataSource.FieldType.String))
.Fields("paramName", fb => fb.Path("paramName").Type(ShieldUI.AspNetCore.Mvc.DataSource.FieldType.String))))
.Sorting(true)
.RowHover(false)
.Columns(cb => cb.Field("orderNumber").Title(Html.DisplayNameFor(t => _actionParView.OrderNumber)).Width(120))
.Columns(cb => cb.Field("isActive").Title(Html.DisplayNameFor(t => _actionParView.isActive)).Width(120))
.Columns(cb => cb.Field("paramType").Title(Html.DisplayNameFor(t => _actionParView.ParamType)).Editor(@<text>ParamTypeSelection</text>).Width(120))
.Columns(cb => cb.Width(140).Title(" ")
.Buttons(b => b.CommandName("edit").Caption("Edit"))
.Buttons(b => b.CommandName("delete").Caption("Delete")))
.Events(ev => ev
.GetCustomEditorValue(@<text>CustomEditorValue</text> )
)
.ToolBar(tb => tb.Buttons(b => b.CommandName("insert").Caption("Add Parameter"))
.Position(ShieldUI.AspNetCore.Mvc.Grid.PositionOptions.Top)
.Buttons(b => b.CommandName("edit").Caption("Edit"))
.Position(ShieldUI.AspNetCore.Mvc.Grid.PositionOptions.Top))
.PagingConfiguration(pb => pb.PageSize(5))
.Editing(eb => eb.Enabled(true)
.Type(ShieldUI.AspNetCore.Mvc.Grid.EditingTypeOptions.Row)))
我添加了一个函数,在Treeview(也是ShieldUI ..)中选择了不同的选项后,它应该更新我的GridView过滤器。
function selectTree(e) {
var actionsGrid = $("#actionsGrid").swidget();
actionsGrid.dataSource.filter.or[0].value = e.item.actionId;
actionsGrid.refresh();
}
如前所述,该功能正在运行,并且正在过滤正确的值,这些值也显示在网格中 - 但是&#34;编辑&#34;和&#34;删除&#34; - 按钮消失了。
非常感谢任何帮助!