Update chart when grid updates

Hi,

I am trying to update my chart control when I update my grid control.

I know I can use the actionComplete() method when this occurs, but I'm having trouble getting the values to show on the chart control.


I bind to the chart using the Model passed to the view, and the object that binds is a List<ExpandoObject>. This is because I need to create this data at runtime:


How do I update the chart when the grid is finished updating?


1 Reply

DG Durga Gopalakrishnan Syncfusion Team November 11, 2021 04:07 PM UTC

Hi Craig, 

Greetings from Syncfusion. 

We request you to use ActionComplete event to update the chart series datasource based on grid data. We have prepared sample which allows you to sort the grid data in ascending or descending order and based on grid update, chart will be updated. Please check with below snippet and sample. 

<script>     
    function actionComplete(args) { 
        var grid = document.getElementById("container1").ej2_instances[0]; 
        var chart = document.getElementById("container2").ej2_instances[0]; 
        if (args.requestType == "sorting") { 
            chart.series[0].dataSource = grid.getCurrentViewRecords(); 
            chart.series[1].dataSource = grid.getCurrentViewRecords(); 
            chart.refresh(); 
        }         
    } 
</script> 

Before Sorting 
 
After Sorting 
 


Please revert us if you have any concerns. 

Regards,  
Durga G

Loader.
Up arrow icon