StefH / KendoGridBinderEx

This is a ModelBinder designed to consume an http request and build a json serializable object for the Kendo UI Grid datasource. AutoMapper is used to support mapping from ViewModel <> Entity.
MIT License
54 stars 24 forks source link

Question: Server paging #27

Closed izhamcheros closed 6 years ago

izhamcheros commented 6 years ago

Hi. Since there is no complete documentation provided for this project, I just want to know if server paging is supported and how to enable it. I need to optimize data loading which is my main concern.

If there no such thing, would you recommend on how do we optimize data loading, for example we query just the 20 data out of 4000 that is needed to be shown on the page (which is sized at 20) but still return the total so the total pages is known to the grid.

I’m using kendogridbinder for c# mvc.

Thanks for your help.

StefH commented 6 years ago

By default server paging will work as default.

Kendogridbinderex creates dynamic sql-queries and uses System.Linq.Dynamic.Core to execute the dynamic query on the database

If you open the example webpage https://kendogridbinderex.azurewebsites.net/Employee

And click the paging buttons, you can also view the generated SQL (right upper corner)

Navigating to 2nd page shows:

SELECT 
    [GroupBy1].[A1] AS [C1]
    FROM ( SELECT 
        COUNT(1) AS [A1]
        FROM [dbo].[KendoGrid_Employee] AS [Extent1]
    )  AS [GroupBy1];

and

SELECT 
    [Extent1].[Id] AS [Id], 
    [Extent1].[EmployeeNumber] AS [EmployeeNumber], 
    [Extent1].[FirstName] AS [FirstName], 
    [Extent1].[LastName] AS [LastName], 
    [Extent1].[Email] AS [Email], 
    [Extent1].[HireDate] AS [HireDate], 
    [Extent1].[Company_Id] AS [Company_Id], 
    [Extent1].[Country_Id] AS [Country_Id], 
    [Extent1].[Function_Id] AS [Function_Id], 
    [Extent1].[SubFunction_Id] AS [SubFunction_Id], 
    [Extent1].[Assigned] AS [Assigned]
    FROM [dbo].[KendoGrid_Employee] AS [Extent1]
    ORDER BY [Extent1].[EmployeeNumber] ASC
    OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY ;
izhamcheros commented 6 years ago

Thanks for the quick reply. I will try it out on the server. Currently, I'm running it remotely (codes running in Malaysia while the database server is in Prague). So in this case, the switch 'serverPaging: true' is not required at all, as I was looking at another project using the original Kendo UI before it was commercialized and I can see that it is being used.

there are other switches like serverSorting, serverFiltering, serverGrouping, and serverAggregates. Does these switches need methods to be defined in C#?

StefH commented 6 years ago

For a simple example, see https://github.com/StefH/KendoGridBinderEx/tree/master/examples/WebApplication.NETCore2

See this https://github.com/StefH/KendoGridBinderEx/tree/master/examples/KendoGridBinderEx.Examples.MVC for a more complex example.

izhamcheros commented 6 years ago

Hi StefH,

I can confirm the serverPaging is working with the serverPaging switch enabled. Thanks a lot for your advice :).

Just another question, if I'm not mistaken, Kendo UI included support for Grid/Persist state for jQuery, Do we have it, or do you have any suggestion how it can be implemented throughout KendoGridBinder?

-Izham-

StefH commented 6 years ago

This project can only query and view data, no updates are possible.

izhamcheros commented 6 years ago

Sorry for the so many questions. I'm really a newbie in programming and I really need help in completing this task in my office.

By the way, I've read somewhere that the Grid Persist can be managed using jQuery's getOption/setOption and I'll explore this option.

My grid is working right now except for sorting and filtering which I thought it should be available by default? When I clicked on the sorting button or try to apply the filtering, it looks like it is sending some request to the server but nothing happened. Is there any function/method that is being called when sorting/filtering is applied? From the examples, I can only see the autocomplete function but not sorting or filtering.

Thanks in advance. Really appreciate your help.

StefH commented 6 years ago

closing....