Jun 24, 2021, 12:16 AM
GridPanel with local paging and ajax proxy
Hi
How to do?
I saw this example with
My example (paging not working).
GridPanel3.cshtml
Ronaldo
How to do?
I saw this example with
memory-proxy
https://forums.ext.net/showthread.ph...-net-Core-Grid, but I need to load store with ajax-proxy
and I didn't find enablePaging="true"
config.My example (paging not working).
GridPanel3.cshtml
@page "{handler?}"
@model ExtSample.Pages.GridPanel3Model
@{
Layout = null;
ViewData["Title"] = "GridPanel";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@ViewData["Title"] - ExtSample</title>
<script type="text/javascript">
var template = '<span style="color:{0};">{1}</span>';
var change = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value);
};
var pctChange = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
};
var load = function () {
App.grid.getStore().load();
};
</script>
</head>
<body>
<ext-button text="Load" margin="10">
<listeners>
<click handler="load();" />
</listeners>
</ext-button>
<ext-gridPanel id="grid" title="GridPanel" width="800" height="500" frame="true" margin="10">
<store>
<ext-store autoLoad="false" pageSize="5">
<fields>
<ext-dataField name="company" />
<ext-numberDataField name="price" />
<ext-numberDataField name="change" />
<ext-numberDataField name="pctChange" />
<ext-dateDataField name="lastChange" dateFormat="yyyy-MM-dd hh:mm:tt" />
</fields>
<proxy>
<ext-ajaxProxy url="GridPanel3/Data">
<reader>
<ext-jsonReader x-rootProperty="result" />
</reader>
</ext-ajaxProxy>
</proxy>
</ext-store>
</store>
<columns>
<ext-column text="Company" dataIndex="company" flex="1" />
<ext-column text="Price" dataIndex="price" renderer="Ext.util.Format.usMoney" />
<ext-column text="Change" dataIndex="change" renderer="change" />
<ext-column text="Change %" dataIndex="pctChange" renderer="pctChange" />
<ext-dateColumn text="Last Updated" dataIndex="lastChange" width="150" format="yyyy-MM-dd" />
</columns>
<bbar>
<ext-pagingToolbar />
</bbar>
</ext-gridPanel>
</body>
</html>
GridPanel3.cshtml.csusing System;
using System.Collections.Generic;
using Ext.Net.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ExtSample.Pages
{
public class GridPanel3Model : PageModel
{
public void OnGet()
{
}
public IActionResult OnGetData()
{
var now = DateTime.Now.ToString("yyyy-MM-dd hh:mm:tt");
var data = new List<object>
{
new object[] { "3m Co", 71.72, 0.02, 0.03, now },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, now },
new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, now },
new object[] { "General Electric Company", 34.14, -0.08, -0.23, now },
new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, now },
new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, now },
new object[] { "Verizon Communications", 35.57, 0.39, 1.11, now },
new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, now }
};
return this.Direct(data);
}
}
}
Any help is appreciated. Thanks!Ronaldo