Custom Loading Message

Id First Name Last Name
370PatrickAdams
493KarenAdams
570NancyAdams
599EricAdams
635ChristineAdams
663BonnieAdams
778RonaldAdams
820SeanAdams
897JudithAdams
857MichaelAlexander
Showing 1 to 10 of 1000 entries

Code

Javascript in View
<script src="~/Scripts/jquery.blockUI.js"></script>
<script type="text/javascript">
	function showLoading() {
		$.blockUI();
	}
	function hideLoading() {
		$.unblockUI();
	}
</script>
        
Inside MVCGridConfig.cs
MVCGridDefinitionTable.Add("CustomLoading", new MVCGridBuilder<Person>(colDefauls)
    .WithAuthorizationType(AuthorizationType.AllowAnonymous)
    .AddColumns(cols =>
    {
        cols.Add("Id").WithSorting(false)
            .WithValueExpression(p => p.Id.ToString());
        cols.Add("FirstName")
            .WithHeaderText("First Name")
            .WithValueExpression(p => p.FirstName);
        cols.Add("LastName").WithHeaderText("Last Name")
            .WithValueExpression(p => p.LastName);
    })
    .WithSorting(true, "LastName")
    .WithPaging(true, 10)
    .WithClientSideLoadingMessageFunctionName("showLoading")
    .WithClientSideLoadingCompleteFunctionName("hideLoading")
    .WithRetrieveDataMethod((context) =>
    {
        var options = context.QueryOptions;
        int totalRecords;
        var repo = DependencyResolver.Current.GetService<IPersonRepository>();
        var items = repo.GetData(out totalRecords, options.GetLimitOffset(), options.GetLimitRowcount(),
            options.GetSortColumnData<string>(), options.SortDirection == SortDirection.Dsc);
        // pause to test loading message
        System.Threading.Thread.Sleep(1000);
        return new QueryResult<Person>()
        {
            Items = items,
            TotalRecords = totalRecords
        };
    })
);
View
@Html.MVCGrid("CustomLoading")