>

Queries

Grids, and TreeViews/TreeGrids may be enhanced with sorting, filtering, and paging capabilities. It is enough to declare the use of a retrievalManager in their fluent interfaces,  to add a pager column in some toolbar, and to declare the columns to be sorted and filtered: 

.CreateStandardQueryResolver(Model.PreviousQuery) //pass initial query
.StartODataRetrievalManager(false//model already filled with data
    "GridExample.QueryModel.RM"//put retrievalManager here
    (uint)Model.PreviousQuery.PageSize, //default page size
    actionUrl: Url.HttpRouteUrl("DefaultApi"//controller Url
        new { httproute = "", controller = "GridsDemoApi" }))

 

.StartToolbar(false)
    ...
    ...
    ...
    .AddPagerColumn("ShortMediumPager")
.EndToolBar()

.StartColumn(t => t.Name, width: 38, widthIsPercentage: true)
    .Queries(truetrue).EndColumn()


A standard User Interface for defining filtering criteria is automatically added when the control is connected to a detail Form:

.DetailFilterBuilder(out detailBuilder, ...)

 

retrievalManagers are javascript objects that handle queries against data sources. User may also manipulate them directly from javascript code ,  and may customize them with new operations. The whole state of a retrievalManager may be saved and restored in order to undo/redo a query operation and/or to connect queries to the Back/Forward Browser buttons. There are basically four types of retrievalManagers:

  1. Submit based. When the user changes someway the “current query”, for instance, by changing a filter condition, or by changing page, a dynamic form is created, filled with adequate input fields that specify all query information, and submitted. The Action Method receives a QueryViewModel object that may be applied to any IQueryable, or IEnumerable. This retrievalManager is the only one that can be used with Server Controls.
  2. Ajax based. When the user changes someway the “current query”, for instance by changing a filter condition, or by changing page, an ajax post with the query information is issued to the server. The Action Method receives a QueryViewModel object that can be applied to any IQueryable, or IEnumerable. The Action method is expected to return json data.
  3. WebApi based. When the user changes someway the “current query”, for instance by changing a filter condition, or by changing page, an oData query is issued to a WebApi controller.
  4. Javascript retrievalManager. It queries a local javascript array.

All retrievalManagers that operate with remote data sources have the option to cache data.