I am trying to use a ShieldUI Data Grid with filtering and editing together. I am using in an ASP.Net core application. The funny thing is - I added the Edit and Delete Button to the rows and it initially seems to work. But when I am trying to change the filter value via javascript function, the correct filtered values are appearing in the rows, but the Edit and Delete Buttons are disappeared and no longer available. I can still use the Insert Button on the Top, but even there I cannot save new values as the Edit/Update Button is no longer visible. Does anyone else having this problem and probably knows a way around this?
This is the 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)))
I added a function, which should update my GridView Filter after I selected a different option in a Treeview (also ShieldUI..).
function selectTree(e) {
var actionsGrid = $("#actionsGrid").swidget();
actionsGrid.dataSource.filter.or[0].value = e.item.actionId;
actionsGrid.refresh();
}
As said previously, the function is working and is filtering the correct values which are also shown in the Grid - but the "Edit" and "Delete" - Buttons have disappeared.
Any help is greatly appreciated!