I have a kendo grid in a view in asp.net MVC application. When i press the delete button(Destroy function) in this kendo grid, a function is called in the controller to delete the object from the database. In the meantime i want to refresh the partial view where this grid is on, in order to refresh the labels in this view. Is it possible to add another jq function to the destroy button for example or is there other solution?
Here is the view code:
<div id="Browsegrid">
@(Html.Kendo().Grid<WEB02.ConfigurationModel.TestGrid>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(110);
columns.Bound(o => o.Type).Width(130);
columns.Command(command => command.Destroy()).Width(110);
})
.Sortable()
.Scrollable(scrollable => scrollable.Virtual(true))
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.Name))
.Events(events =>
{
events.RequestEnd("onRequestEnd");
})
.PageSize(100)
.Read(read => read.Action("TestGrid", "Configuration"))
.Destroy("TestDelete", "Configuration")
)
.Pageable(pageable => pageable
.Refresh(true))
)
</div>
The script part: It calls a ajax request calling a method in the controller to view the partial view.
<script>
function onRequestEnd(e) {
$.ajax({
url: '/Configuration/_WorkflowPartial',
contentType: 'application/html charset=utf-8',
type: 'GET',
dataType: 'html',
data: { 'nodeName': NN, 'nodeType': NT, 'nodeID': NI, 'nodeURL': NU },
success: function (data) {
$('#body').html(data);
}
})
}
</script>
labels
in this view what exactly do you mean? In your grid you have a.Refresh
function which I gather just refreshes the grid so the deleted value disappears? – Canvas.Events(events => { events.RequestEnd("onRequestEnd"); //I've added this })
then you can just calllocation.reload();
in the event – Canvas