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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get count async

Thread ID:

Created:

Updated:

Platform:

Replies:

144800 May 23,2019 10:46 AM UTC May 30,2019 01:26 PM UTC Angular - EJ 2 4
loading
Tags: Grid
Marko
Asked On May 23, 2019 10:46 AM UTC

Hi Team,

I working on application which will return many objects to grid.
When I send query to API I got back many records and total count of SQL table.

However, that cause slowly SQL query. When I remove COUNT(*) from query then I got good speed.

Can I update total count dynamically, for example.
Get results from table to grid, then send query to API for count of table.

After I got total count, cache total count on client side. When I change Filter, then I call again count and cache.

Regards

Marko
Replied On May 23, 2019 01:28 PM UTC

Hi,

How I can set totalcount to grid over typescript?


Thavasianand Sankaranarayanan [Syncfusion]
Replied On May 27, 2019 12:56 PM UTC

Hi Marko, 

Greeting from Syncfusion support. 
 
Query 1: Get results from table to grid, then send query to API for count of table. 
 
We have validated the provided information and by default we have an option to handle on-demand grid actions using data manager and its helps you to improve better performance for large data. 

Please refer the below code example and documentation for more information. 

[fetchdata.component.html] 
<ejs-grid #grid [dataSource]='data' allowGrouping="true" allowFiltering="true" allowPaging="true" allowSorting="true" height="320"> 
    <e-columns> 
        <e-column field='OrderID' headerText='Order ID' isPrimaryKey=true width='150'></e-column> 
        <e-column field='CustomerID' headerText='Customer Name' width='150'></e-column> 
        <e-column field='ShipCity' headerText='ShipCity' width='150' textAlign='Right'></e-column>       
    </e-columns> 
</ejs-grid> 

ngOnInit(): void { 
    this.data = new DataManager({ 
        url: 'Home/UrlDatasource', 
        adaptor: new UrlAdaptor 
    }); 
  } 

    public IActionResult UrlDatasource([FromBody]DataManagerRequest dm) 
        { 
 
            IEnumerable DataSource = OrdersDetails.GetAllRecords(); 
            DataOperations operation = new DataOperations(); 
            . . . . . 
           int count = DataSource.Cast<OrdersDetails>().Count(); // Total Count of the Grid DataSource  
            if (dm.Skip != 0) 
            { 
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging 
            } 
            if (dm.Take != 0) 
            { 
                DataSource = operation.PerformTake(DataSource, dm.Take); 
            } 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count}) : Json(DataSource); 
        } 

 




If the above solution does not meet your requirement then share more details and code example that will helpful for us to provide a better solution as soon as possible. 
 
Query 2: How I can set totalcount to grid over typescript? 
 
By default if we using UrlAdaptor for Grid data binding then we return the total count from server side itself. So, please share more details on requirement to provide better assistance from our end. 

Regards, 
Thavasianand S. 


Marko
Replied On May 27, 2019 01:05 PM UTC

Hi,

That resolution will not work for me.

I have exposed store procedure which handle data.
There is one store procedure which will get total count of table. That store procedure call only when Data is initialize, and when filter changed.

So I want dynamically set total count to grid. When I only change filter then I call store procedure which will return total count of records in specific table.

Also, I don't use url adaptor, I use observables.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On May 30, 2019 01:26 PM UTC

Hi Marko, 

Thanks for your update. 

We have analyzed your requirement and we suggest you to use the forkJoin function of observables to achieve your requirement. You can create observables and get the result (JSON data) and create another observables to get the count value after that you can join both the observables by using forkJoin and return the final result to the Grid. 

Please refer the below reference link for more information. 



Regards, 
Thavasianand S. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon