I am trying to implement paging toolbar on extjs grid pangel using c# backend... How do I start doing about that... I have tried using start and limit but I am not sure how it works. could someone please help me on how I can just send about 20 records per page in the grid, because my grid is getting all 500 datas, which is slowing my application as well below is my controller that sends json to my store.. Please help
public JsonResult getData(int start, int limit)
{
List<MyItem> items = new List<MyItem>();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices1"].ConnectionString))
{
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "SELECT State, Capital FROM MYDBTABLE";
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
MyItem item = new MyItem();
item.State = reader[0].ToString();
item.Capital = reader[1].ToString();
items.Add(item);
}
con.Close();
return Json(new { myTable = items }, JsonRequestBehavior.AllowGet);
}
}
and this is my store
this.store = Ext.create('Ext.data.JsonStore', {
autoLoad: true,
storeId: 'mystore1',
pageSize: 20,
fields: [
{ name: 'State' },
{ name: 'Capital' }
],
sorters: [
{
property: 'State',
direct: 'ASC'
}],
scope: this,
proxy: {
type: 'ajax',
scope: this,
url: 'StateC/getData',
autoLoad: { params: {
start: 0,
limit: 20
}
},
reader: {
type: 'json',
root: 'myTable'
}
}
});