Datasource gets called 3/4 Times in Grid

Hello,

This Razor code:
@(Html.EJS().Grid("DataGrid")
                                .DataSource(dataManger =>
                                {
                                    dataManger.Url("/Formulari/GetDataTable").Adaptor("UrlAdaptor");
                                })
                                .Query("new ej.data.Query().addParams('extra', '" + parameters + "')")
                                .GridLines(GridLine.Both)
                                .AllowPaging()
                                .AllowSorting()
                                .PageSettings(page => page.PageSize(50))
                                .Columns(col =>
                                {
                                    col.Field("CodiceGrif").HeaderText("Partita").Template("#codeColumn").Width("30%").Add();
                                    col.Field("CodiceCir").HeaderText("CIR").Width("90").HideAtMedia(MediaQuery.ColLg).Add();
                                    col.Field("RagioneSocialeOrigine").HeaderText("Produttore").Width("30%").Add();
                                    col.Field("Quantita").HeaderText("Q.ta").Format("N2").Width("70").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
                                    col.HeaderText("Azioni").Template("#selectColumn").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width("80").HideAtMedia(MediaQuery.ColMd).Add();
                                }).Render()
                        )

Gets my datasource to be called 3 times. I've also noticed that on resize, the datasource gets called at every boostrap "step" (991px -> 768px etc.)

Any suggestion on what to check?

Edit:
To be 100% sure it was not a third party library conflict, I created a simple test page with only ej2.js and ej css., result is almost the same. DataSource gets called 2 times, and it still gets called on resizes. Here below, the source code generated for the test page:


4 Replies

DA Daniele March 14, 2018 10:31 AM UTC

Edit:
Removed test page source code, as I found the cause of the problem:
.HideAtMedia()

If I remove the HideAtMedia property the Datasource gets called only once, correctly.
How can I prevent this to happen?


DR Dhivya Rajendran Syncfusion Team March 15, 2018 12:42 PM UTC

Hi Daniele, 
Thanks for contacting Syncfusion support, 
We have analyzed your query, We confirmed that the issue with “DataSource called more times when enable HideAtMedia property is a defect and we have logged a defect report. The fix for this issue is estimated to be available in our upcoming release. 

Regards,
R.Dhivya 



DA Daniele March 15, 2018 03:13 PM UTC

Hello, thanks for your support.

After a little more investigation done before your reply, I've found out that the Datasource is always called 2 times at page load (1 correctly, 1 for the hideAtMedia bug) and an extra 3rd time is caused by the localization: After loading the required .json cldr files
document.addEventListener('DOMContentLoaded', function () {
 ej.base.setCulture('it');
}); 
causes an extra call to the datasource.
Moving it outside the DOMContentLoaded  (or jquery's document.ready()), does not cause the extra call.

Can you check it? 

Thank you






RU Ramdhas  Ueikattan Syncfusion Team March 16, 2018 12:49 PM UTC

Hi Daniele, 

Thanks for your update. 

We have validated your query. While you calling the ‘setCulture method the syncfusion components have refreshed to adopt the culture changes. The grid doesn’t persist the dataSource value in refreshing so that the grid calls DataSource method for changing the culture value. 

This is a default behavior of the grid.  


Regards, 
Ramdhas  Ueikattan 


Loader.
Up arrow icon