Is there a way to trigger a function when no rows or no data in the grid?

Hi,  I tried a lot of functions as you see here in my grid :

 var grid = new ej.grids.Grid({

                        actionComplete: onActionComplete,

                        dataSource: data,

                        dataBound: dataBound,

                        actionComlete: actionComlete,

                        created: created,

                        toolbar: ['Search'],

                        allowPaging: true,

                        rowSelected: rowSelected,

                        actionBegin: onActionBegin,

                        gridLines: 'Both',

                        height: '200',

                        width: "100%",

                        pageSettings: {

                            currentPage: 1.0,

                            pageCount: 8.0,

                            pageSize: 5.0

                        }

                    });

But no one achieves my requirement.

Is there a way to trigger a function when no rows or no data in the grid?

Could you please help me with this? I would like to know which event to use.


1 Reply

PS Pavithra Subramaniyam Syncfusion Team November 15, 2021 09:27 AM UTC


Hi zohir, 

Thanks for contacting Syncfusion support. 

The ‘beforeDataBound’ event will be triggered even the Grid has no data. And if any failure occurs while binding data then Grid will show no records and the ‘actionFailure’ event will be triggered for this case. Please refer to the below code example and documentation link for more information. 

var grid = new ej.grids.Grid({ 
  dataSource: [], 
 
  beforeDataBound: beforeDataBound, 
 
  actionFailure: actionFailure, 
  .  .  . 
}); 
grid.appendTo('#Grid'); 
 
function beforeDataBound(args) { 
  console.log(args.result.length); 
} 
 
function actionFailure(args) { 
  console.log(args); 
} 


                             https://ej2.syncfusion.com/documentation/api/grid/#actionfailure 

Sample               : https://stackblitz.com/edit/duzjuv 

Please get back to us if you have any queries. 

Regards, 
Pavithra S 


Loader.
Up arrow icon