How to display a loading image until a gridview is fully loaded without Ajax Toolkit?

前端 未结 6 679
一个人的身影
一个人的身影 2021-01-03 06:10

QUESTION

Can anyone suggest how a loading image can be displayed until a gridview is fully loaded?

This gridview is to be rendered on page

6条回答
  •  别那么骄傲
    2021-01-03 06:25

    I would implement this by using a web api controller that returns the appropriate data and then simply try to load the data on document.ready with jquery. Something along the lines of this (Will be posting the answer in c# but it should be simple enough to translate):

     public class TableDataController : ApiController
      {
         public IEnumerable Get()
         {
            var tableData = GetTableDataFromSomewhere();
    
            return tableData;
         }
      }
    

    To learn more about how to setup a WebApiController in a web forms project, please refer to this article.

    I would implement the HTML something like this:

    And the jquery to load the data and present it in the table would look something like this:

    
    

    To tidy the string concatenation of the jQuery up a bit you could use a template like handlebars, but it's not strictly necessary.

提交回复
热议问题