This is a simple aggrid with web api framework, aim to use aggrid with web api on .net core.
Simply, aggrid send params to server, and transfer to procedure then get data from Database.
- parameter(filterModels, sortModels..): Client(browser) => Server(.net core 2.2) => Oracle DB(procedure)
- Infinite Mode: Pagination, Filter, Sort
- Server Mode: Pagination, Filter, Sort, Group by
- Front End: Ag-grid + JavaScript
- Server: Web API + ADO.Net(No EF)
- DataBase: Oracle: procedure
- 显示大数据量,考虑到控件自身的功能丰富度和support, 前端使用ag-grid控件
- 容器化, 使用.net core 2.2框架
- 兼容移动端, 使用web api
- 为了更好的利用已有的存储过程, 未使用EF, 通过 ADO.Net获取数据库数据.
- Config files
- launchSettings.json: 默认的程序启动配置文件
- dbsettings.json: 配置数据库连接字符串
- Startup.cs: 配置和注入服务
//add mvc serv
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
//inject costumed instance
// Scoped objects are the same within a request but different across requests.
services.AddScoped<IDemo, Demo>();
- Controller: DI+RESTful
[Route("api/aggrid")]
[ApiController]
public class AgGridController : ControllerBase
{
private readonly IAGServer _aGServer;
private readonly IRequestBuilder _requestBuilder;
public AgGridController(IAGServer aGServer, IRequestBuilder requestBuilder)
{
_aGServer = aGServer;
_requestBuilder = requestBuilder;
}
[HttpGet]
[Route("GetDataColumns/{datasource}")]
public Task<string> GetDataColumns(string datasource)
{
return Task.Run(() => _aGServer.GetDataColumns(datasource));
}
...
}
- wwwroot: 前端文件
定义接口及其实现类
- 在startup文件中完成注入
services.AddScoped<IAGServer, AGServer>();
. - 在消费类的构造函数中添加接口类IDemo作为参数
public AgGridController(IAGServer aGServer, IRequestBuilder requestBuilder)
, - .net core运行时作为一个容器, 在调用服务时自动注入AGServer实例
- IAGServer.cs 接口类
- AGServer.cs 结构实现类
- 映射表格参数filterModels, sortModels...
- 生成表格列名
- 辅助函数
- 静态常量
- 使用ADO.Net调用存储过程, 获取数据.
- 示例文件: 参数及处理逻辑
- Not use Entity Framework, based on ADO.Net + procedure
- ag-grid started
- ag-grid row model support function comparisons
- ag-grid grid features