We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Empty

How can i have an empty grid on page load and refill it later with some search parameters?
Now I', getting an error that grid cannot be empty on load.

1 Reply

AS Alan Sangeeth S Syncfusion Team July 18, 2016 05:57 AM UTC

Hi Hrvoje, 

Thanks for using Syncfusion products. 

Query 1: “empty grid on page load and refill it later” 

We are glad to let you know that we have achieved your requirement and created a sample which can downloadable from below link. 


In the above sample we have not bounded any data to Grid control at initial load. On a button click event, using DataManager we have sent post-back to retrieve data from server-side and we have used addParams” method of ejQuery to send additional parameter. Then in DataManager done event, we have updated data to grid using “dataSource” Grid method. Please refer to the following code example and documentation links. 
<ej:Button ID="ButtonNormal" runat="server" Type="Button" ClientSideOnClick="ButtonNormal_Click" Text="Update Grid"></ej:Button> 
    <ej:Grid ID="EmployeesGrid2" runat="server" AllowPaging="True"> 
 
</ej:Grid> 
 
    <script> 
        function ButtonNormal_Click(args) { 
            var gridObj = $('#<%= EmployeesGrid2.ClientID %>').data("ejGrid"); 
            var query = new ej.Query().addParams("param23", 5); 
            $('#<%= EmployeesGrid2.ClientID %>').ejWaitingPopup("show"); 
            ej.DataManager({ url: "Default.aspx/DataSource", adaptor: new ej.WebMethodAdaptor()}).executeQuery(query).done(function (e) { 
                gridObj.dataSource(e.result); 
                $('#<%= EmployeesGrid2.ClientID %>').ejWaitingPopup("hide"); 
            }); 
        } 
    </script> 


Documentation links: 

 
Query 2: “getting an error that grid cannot be empty on load 

We suspect that you have not defined any Grid columns and loaded empty data which may be the cause of the issue.  

It is necessary to provide either datasource or define Grid columns at initial load. When we do not provide both datasource and Grid columns, it is not feasible to render Grid since there is no information on number of columns and its names. 

Regards,
Alan Sangeeth S 


Loader.
Live Chat Icon For mobile
Up arrow icon