Reputation: 1851
I am working on asp.net mvc 3. I am trying to display list of records using kendo mvc ui grid. and i have set editable mode to popup so the processing could be done on server. I want to display loading image before data is loading into the grid that means during paging,refreshing etc. I have used the grid like
@(Html.Kendo().Grid(Model)
.Name("GrdXXX")
.HtmlAttributes(new { style="width:1000px;" })
.Columns(columns =>
{
columns.Bound(p => p.xxx).Width(50);
columns.Bound(p => p.yyy).Width(50);
columns.Bound(p => p.zzz).Width(80);
columns.Bound(p => p.State).Width(50);
columns.Bound(p => p.Phone).Width(70);
columns.Command(command => { command.Edit().Text("Edit Details"); command.Destroy().HtmlAttributes(new { onclick = "return DeleteConfirm();" }); }).Width(120);
})
.ToolBar(toolbar => toolbar.Create().Text("Add New Zip Code"))
.Editable(editable => editable.Mode(GridEditMode.PopUp).Window(m => m.Title("Edit Zipcode").Draggable().Resizable()))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(p => p.RecNo))
.Update("Update", "ghj")
.Create("Create", "ghj")
.Destroy("Delete", "ghj")
)
)
I have tried using ajax jquery calls but it doesnt work for me. so please guide me.
Upvotes: 1
Views: 18285
Reputation: 21420
A better solution as recommended by Telerik:
// show loading indicator
kendo.ui.progress($element, true);
// hide loading indicator
kendo.ui.progress($element, false);
// $element is a jQuery object. The element must have a position:relative style applied
Upvotes: 2
Reputation: 12346
This is how I solved explicitly adding loading effect to Kendo grid by extending jQuery. It uses the native Kendo styling.
$.extend($.fn, {
busy: function (c) {
b = $(this);
var d = b.find(".k-loading-mask");
c ? d.length || (d = $("<div class='k-loading-mask'><span class='k-loading-text'>Loading...</span><div class='k-loading-image'/><div class='k-loading-color'/></div>").width(b.outerWidth()).height(b.outerHeight()).prependTo(b)) : d && d.remove()
}
});
And then use it as
$("#grid").busy(true); // change to false to hide loading effect
Upvotes: 6
Reputation: 30661
The grid will display a loading image automatically if it were configured for ajax binding. Your grid is configured for server binding which relies on regular HTTP GET requests (no Ajax). A loading image would be immediately removed once the browser starts making the HTTP GET request.
Upvotes: 0