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

To Clear the Datasource for Grid

we are using the javascript api for binding data to Grid and Chart by consuming data from WCF service, everything works fine , but we added the search options using the DataPicker so here data is fetched properly , but old data in the grid is not cleared . we want to clear the data and bind the fresh data.
In chart we have search option based upon date, the data is being appended to existing data. so the chart is getting disturbed.

how to clear the datasource for Grid and how to clear the Chart.

We tried doing
      $('#Container').ejGrid();  ---> without parameters
      $('#Container').ejChart(); ---> without parameters
is it storing the old data in cache or cookies ?



9 Replies

RS Ram Sagar Mourya August 30, 2013 08:19 AM UTC

Is there anybody from syncfusion ?


YO Yogeshwaran Syncfusion Team September 2, 2013 07:18 AM UTC

 Hi Ram Sagar Mourya,

 

Thanks for using Syncfusion products.please find the response for your query.

 

how to clear the datasource for Grid

To clear dataSource in grid . please use below code :

 

$("#Grid").ejGrid("option", { dataSource: [] });

 

For your convenience, we have created below sample sample to clear dataSource of grid.

 

Sample:

ejGrid.zip

 

 

Please let us know if you have any concerns.

 

Regards,

Yogesh R



GS Gowrimathi S Syncfusion Team September 3, 2013 08:16 AM UTC

Hi Ram Sagar Mourya ,

Thanks for using syncfusion product. please find the response.

To clear the chart, use the below code

$("#chart").ejChart("option":{datasource:[]});

We have prepared the sample based on the query. please find the sample in the attachment

Regards

Gowrimathi S



ejChart_6163d6bc.zip


RS Ram Sagar Mourya September 3, 2013 08:45 AM UTC

Hi Yogeshwaran ,

thanks for the reply, we modified the code ,
we are facing two issues :
1.The grid is being cleared when allowinPaging is set to true, data fetched for first few pages of the grid show correct data, but when we click on say page no 10 old data is still available in the grid. we also checked whether the data is wrong or what so, but data is correct. there is some issue with filtered data(search with dates) being bind to the grid.

2.It is not working when allowinPaging is set to false, i mean grid is not being cleared. we are attaching screen showing the firebug error.

may there is need to clear the gridPager also.

plz let us know.

Thanks
Ram Sagar Mourya



syncfusion_grid_8bb7e1b2.zip


YO Yogeshwaran Syncfusion Team September 11, 2013 09:23 AM UTC

 

 Hi Ram Sagar Mourya,

 

Please find the response.

 

Filtered data is bound to grid after dataSource is cleared.

We have provided workaround to avoid the issue “Filtering collection is not cleared after binding new dataSource to grid”. Please find the workaround for this issue.

[code]

$("#clearData").click(function () {

  $("#Grid").ejGrid("option", { dataSource: [] });

  var instance = $("#Grid").ejGrid("instance");

  instance._filterCollection = [];

});

 

Sample:

ejGrid.zip

 

Also we have considered, this as issue . The fix for this issue will available on our upcoming release .

 

Issue with grid pager while clearing and updating dataSource

Thanks for your information, we can reproduce issue with provided data.  The fix for issue “getGridPager is null“ will be available on our upcoming release.

 

Please let us know if you have any further assistance .

 

Regards,

Yogesh R



MC Márcio Chaves replied to Yogeshwaran November 17, 2014 05:10 PM UTC

 Hi Ram Sagar Mourya,

 

Thanks for using Syncfusion products.please find the response for your query.

 

how to clear the datasource for Grid

To clear dataSource in grid . please use below code :

 

$("#Grid").ejGrid("option", { dataSource: [] });

 

For your convenience, we have created below sample sample to clear dataSource of grid.

 

Sample:

ejGrid.zip

 

 

Please let us know if you have any concerns.

 

Regards,

Yogesh R


Can I use this same method to clear a TreeGrid? I tried but isn't woking well.


SA Saravanan Arunachalam Syncfusion Team April 21, 2017 06:08 AM UTC

Hi Ram Sagar Mourya, 
In TreeGrid, we can empty/add new data source dynamically by using below code snippet.  
function updateDataSource(){  
        $("#TreeGridContainer").ejTreeGrid("option","dataSource",[]);  
      }  
We have prepared a sample and empty the datasource on button click action, please find the sample link below,  
Please let us know if you require further assistance on this.  
Regards,  
Saravanan A. 



WB Wojciech Boczarski June 9, 2017 02:05 PM UTC

Hi

How can I clear data if im using ejChart? Seems to have the same problem. 

Thank you


SA Saravanan Arunachalam Syncfusion Team June 12, 2017 12:13 PM UTC

Hi Ram Sagar,  
Sorry for the inconvenience.   
We have analyzed your query.  As of now we are having an issue in updating the chart with empty data source, so we have logged issue report on “Empty data source is assigned to the series on events, chart is not updated” and fix for the reported issue will be included in our Essential Studio 2017 Volume 2 SP 2 release, which is expected to be out at the end of June 2017. 
Saravanan A. 


Loader.
Live Chat Icon For mobile
Up arrow icon