IgniteUI / ignite-ui

Ignite UI for jQuery by Infragistics
https://bit.ly/2kuu1fT
Other
477 stars 84 forks source link

Re-add TotalRecordsCount member in the GridPaging feature in asp .net core Gridmodel #2189

Closed absinghal closed 1 year ago

absinghal commented 2 years ago

Is your feature request related to a problem? Please describe.

Converted igGrid from Asp .net MVC to Asp .net Core.

Earlier there used to be a TotalRecordsCount member in the GridPaging feature.

Mentioned here https://www.infragistics.com/community/forums/f/ignite-ui-for-jquery/74927/server-side-paging/379131#379131

Now this member is not found.

Describe the solution you'd like

should be added back to be able to specify TotalRecordsCount in the initial load of the grid with gridpaging enabled.

Describe alternatives you've considered

Grid is bound to dataset on the server side at the time of initial load. The columns and structure are not known ahead of time, so conversion to a typed model is not possible.

Additional context

https://www.infragistics.com/community/forums/f/ignite-ui-for-asp-net-core/124170/totalrecordscount/544482?focus=true#544482,

absinghal commented 1 year ago

Hello @hanastasov

Any ETA for this issue ?

Thanks

absinghal commented 1 year ago

Hi @dkamburov

To see this live in action, pl visit http://freeten.livmatter.com/app/index?publisher=FreeTen&Product=AdventureDemo&Audience=Public&appcode=advdem

and select orders from sale menu

Grid shows only 1-100 of 100 records, where as there are total 119 records, because the TotalRecordsCount property is not working. We are using server side binding to a dataset.

hanastasov commented 1 year ago

Hi @dkamburov

To see this live in action, pl visit http://freeten.livmatter.com/app/index?publisher=FreeTen&Product=AdventureDemo&Audience=Public&appcode=advdem

and select orders from sale menu

Grid shows only 1-100 of 100 records, where as there are total 119 records, because the TotalRecordsCount property is not working. We are using server side binding to a dataset.

Are you sure this is the issue? It seems to me that your data returns only 16 records at all:

image

https://freeten.livmatter.com/App/PageData?publisher=FreeTen&Product=AdventureDemo&Audience=Public&appcode=advdem&state=H4sIAAAAAAAACmSQMQvCMBCFd8H%2FUDK7OOjgViui2C4qIohDaE4IpE1pz2op%2Fe%2FeJWgKTkm%2B9%2B7dXfrpJIpEXFWJVSBWkZCqVVCImeNni9IcIbe1SuyzRDLMl17a6QZt3Z1QItf1DAlfNLzCk8ABOo5NyR676A1UssYCKM0lOVfmuy8C2as31408W22wGWcTa6VhdLv%2FbLxNjroFavwvKZ3TrkazEDAJNJUI4P69DuOBrlnqRvJo4MPrHLuWJf1R%2BeABSRo%2BAAAA%2F%2F8DAFcBr%2BhZAQAA**&page=0&pageSize=100**&_=1659435873254

absinghal commented 1 year ago

As suggested in previous post, pl click on Sale Menu > Orders Menu item. Here is a screenshot:

image

absinghal commented 1 year ago

For checking the json payload returned by the Sale>Orders menu item, you may check in the browser dev tools network tab.

Here it is attached for easy reference. As you can see server returns "TotalRecordsCount":100 --> found no means to set this value on server side

igniteui-payload.txt .

MayaKirova commented 1 year ago

@absinghal In general binding to a data set has some limitations as described in the documentation: https://www.igniteui.com/help/ighierarchicalgrid-binding-to-dataset#binding

However paging is one of the supported remote scenarios. We also have a sample that demonstrates it here: https://www.igniteui.com/hierarchical-grid/dataset-binding And with that setup the total number of records in the table gets populated in TotalRecordsCount and the records for the current page get populated in Records.

Not sure why you would need an additional property for this scenario. Does the total records count differ than the actual number of records in your table? For example does your data base returns only a small part of the data in your data table so your data table does not hold the full data when you bind it to the grid?

absinghal commented 1 year ago

@MayaKirova yes in our case, we have the data base return only a small part of the data in our data table so that our data table does not hold the full data when we bind it to the grid. This is because full data may be very large.

In IgniteUI for Asp .net MVC we used to implement a CustomGridPaging class as follows

Class CustomGridPaging
    Inherits GridPaging
    Public Property TotalRecordsCount As Integer
    Public Overrides Sub TransformDataSource(ByVal queryString As NameValueCollection, ByVal grid As IGridModel, <Out> ByRef queryable As IQueryable)
        MyBase.TransformDataSource(queryString, grid, queryable)
         Me.Store("totalRecordsCount") = Me.TotalRecordsCount
    End Sub
End Class

And use as follows (PageCount and TotalCount are local variables)

  myGrid.Features.Add(New CustomGridPaging() With {.Type = OpType.Remote, .Inherit = True,
                                    .PageSize =PageCount, .TotalRecordsCount = TotalCount,
                                    .PageSizeList = New List(Of Integer)({100, 500, 1000})})

But above method does not work in asp .net core version

absinghal commented 1 year ago

@MayaKirova tested above again in asp .net core and found issue with something else in our code base. Lots of things changed during our upgrade to asp .net core, and this issue wrongly got attributed to Ignite UI asp .net core version.

So if you are fine with above method, we are good to go and can close this issue.

Thanks for having a look at this.

MayaKirova commented 1 year ago

@absinghal Thanks for letting me know. In general we have made this property TotalRecordsCount internal a while ago (around version 16.1) since we consider it something internal for our paging implementation. You can use your own custom paging if you'd like and overwrite the response methods, for example:

    public class CustomPaging : GridPaging
    {
        public int MyTotalCount { get; set; }
        public override void TransformDataSource(IQueryCollection queryString, IGridModel grid, out IQueryable queryable)
        {
            base.TransformDataSource(queryString, grid, out queryable);
            // set your custom count
            this.MyTotalCount = 100;
        }
        public override void HandleResponse(LargeJsonResult result)
        {
            WrappedGridResponse response = result.Value as WrappedGridResponse;
            response.TotalRecordsCount = this.MyTotalCount;
        }
        public override void HandleResponse(WrappedGridResponse response)
        {
            response.TotalRecordsCount = this.MyTotalCount;
        }
    }

Just note that some features like the [GridDataSourceAction] attribute will not work out of the box with the custom paging. You will have to use the GridModel where you added the custom paging feature to get the data for any remote endpoints.

Hope this helps.

absinghal commented 1 year ago

Thanks @MayaKirova

Yes, custom paging is already implemented in our low/no code framework (sample app here), which uses many controls of IgniteUI.