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.
Unfortunately, activation email could not send to your email. Please try again.

Find grid empty or not

Thread ID:

Created:

Updated:

Platform:

Replies:

130246 May 2,2017 06:10 AM May 3,2017 05:48 AM ASP.NET Web Forms 1
loading
Tags: Grid
Pratheep
Asked On May 2, 2017 06:10 AM

Hi

Jquery how to find grid empty or not ?

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

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

}

Thanks
Pratheep

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 3, 2017 05:48 AM

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; 
     
      if(Productobject>1) 
        //do stuff 
 
If we misunderstood your query, then could you please provide more details about your requirement? 
Regards, 
Venkatesh Ayothiraman. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;