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

Find grid empty or not


Jquery how to find grid empty or not ?

        var Productgrid = $('#GridProduct').ejGrid("instance");
        var Productobject = JSON.stringify(grid.model.dataSource);

if ( Productobject == "" || Productobject == null)



1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team May 3, 2017 09:48 AM UTC

Hi Pratheep, 
Thanks for contacting Syncfusion support. 

We went through your code example that you have shared for us and found that you are trying to check whether data source is bound to Grid or not. If so, your code example is not recommended way to find the data source is empty or not, because, it works only if you are binding local json data to the grid datasource, not for remote data/adaptors used as grid datasource. And you were get the grid object like “$('#GridProduct').ejGrid("instance");” in such case, it may throws the script error when Grid is not rendered at initial time. So, we suggest you to use the following code example to get the grid instance, 
Code example
<external button Click event> 
function buttonClick(args) { 
                var Productgrid = $('#GridProduct').data("ejGrid"); // create a grid instance. 
                     //do stuff             
Do you want to check the Grid data source is empty? If so, we suggest you to use the currentViewData object to find the Grid data source is empty or not. It can be used for both local data source and remote data source/adaptors. Please refer to the following code example,  
    var Productgrid = $('#GridProduct').data("ejGrid"); // create a grid instance. 
    var Productobject = Productgrid.model.currentViewData.length; 
        //do stuff 
If we misunderstood your query, then could you please provide more details about your requirement? 
Venkatesh Ayothiraman. 

Live Chat Icon For mobile
Up arrow icon