PDA

View Full Version : Paging the grid is not displaying results



Sai Dasika
12 Feb 2010, 5:18 AM
getting a problem with paging the code is as follows:

the store is as follows written in JSCRIPT:

var store = new Ext.data.Store({
url:'SearchHandler.ashx',
reader: new Ext.data.JsonReader({
root:'rows',
totalProperty:'total',
id:'ID'
}, [
'ID',
'First_Name',
'Last_Name',
'Telephone_Number',
'e_mail',
'Address'
])

});
store.load({params:{start:0,limit:3}});

my generic handler code


int start=int.Parse(context.Request.Params["start"]);
int limit=int.Parse(context.Request.Params["limit"]);
using (TelephoneBookDataContext dataContext = new TelephoneBookDataContext())
{
dataList = (from c in dataContext.TelephoneNumbers
where c.Record_Owner == username && (c.First_Name.Contains(SearchString) || c.Last_Name.Contains(SearchString) || c.Telephone_Number.Contains(SearchString) || c.e_mail.Contains(SearchString) || c.address.Contains(SearchString))
select c).ToList();


}
int total;

int rowLimit=start+limit;
total = dataList.Count;
String json = "";

int row = 0;
for (int j = 1; ; j++)
{

if ((row + 1) < dataList.Count)
{
json += "[";
if ((dataList.Count - row) > start && (dataList.Count - row) < limit)
{
rowLimit = dataList.Count - ((j - 1) * rowLimit);
}
for (int i = 0; i < rowLimit; i++)
{

json = json + "{";
json += "\"ID\"" + ":" + "\"" + dataList[row].ID + "\"" + ",";
json += "\"First_Name\"" + ":" + "\"" + dataList[row].First_Name + "\"" + ",";
json += "\"Last_Name\"" + ":" + "\"" + dataList[row].Last_Name + "\"" + ",";
json += "\"Telephone_Number\"" + ":" + "\"" + dataList[row].Telephone_Number + "\"" + ",";
json += "\"e_mail\"" + ":" + "\"" + dataList[row].e_mail + "\"" + ",";
json += "\"Address\"" + ":" + "\"" + dataList[row].address + "\"";
json = json + "}";
if (i != (rowLimit - 1))
{
json += ",";
}
row++;
}
if (dataList.Count / (j * 3) == 0)
{
json += "]";
}
else
{
json += "],";
}
}
else
{
break;
}
}

if (dataList.Count != 0)
{
context.Response.Write("{success:true,total:"+total+",rows:" + json + "}");
}

The Json string written to the grid is like this

"[{\"ID\":\"1\",\"First_Name\":\"Naren\",\"Last_Name\":\"Koka\",\"Telephone_Number\":\"100-62311335\",\"e_mail\":\"[email protected]\",\"Address\":\"address\"},{\"ID\":\"4\",\"First_Name\":\"Kiran\",\"Last_Name\":\"Pakala\",\"Telephone_Number\":\"100-6874123\",\"e_mail\":\"kiran.pakala\",\"Address\":\"US\"},{\"ID\":\"10\",\"First_Name\":\"Sai\",\"Last_Name\":\"Dasika\",\"Telephone_Number\":\"91-9052134782\",\"e_mail\":\"[email protected]\",\"Address\":\"US\"}],[{\"ID\":\"11\",\"First_Name\":\"Sundar\",\"Last_Name\":\"Ramadoss\",\"Telephone_Number\":\"63699887\",\"e_mail\":\"[email protected]\",\"Address\":\"US\"},{\"ID\":\"23\",\"First_Name\":\"Sujatha\",\"Last_Name\":\"Sagar\",\"Telephone_Number\":\"2560845\",\"e_mail\":\"[email protected]\",\"Address\":\"Seethammapeta,Vizag\"},{\"ID\":\"34\",\"First_Name\":\"Santhi\",\"Last_Name\":\"Dasika\",\"Telephone_Number\":\"2560408\",\"e_mail\":\"[email protected]\",\"Address\":\"rajendranagar\"}],[{\"ID\":\"46\",\"First_Name\":\"dsf\",\"Last_Name\":\"dsf\",\"Telephone_Number\":\"dsf\",\"e_mail\":\"sdf\",\"Address\":\"sdf\"},{\"ID\":\"47\",\"First_Name\":\"dsf\",\"Last_Name\":\"dsf\",\"Telephone_Number\":\"dsf\",\"e_mail\":\"sdf\",\"Address\":\"sdf\"}]"


BUT The grid is not displaying any rows or the paging.
FYI:I am able to display all the rows in ain single page but not when using paging.

PLEASE HELP!
Thanx in advance,
Sai Dasika.

tryanDLS
12 Feb 2010, 9:25 AM
Thread moderation is on - please do not double post.

http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

Frith
15 Feb 2010, 7:03 AM
I'm assuming that the JSON you listed is the content of the json variable.

I would suggest that you take the entire json string and run it through jsonlint.com

It suggests that the string should be:

{"success":"true","total":"7","rows":[ ]"}

Note the quotes around each key and value

Sai Dasika
15 Feb 2010, 7:36 AM
Hi,
Thanq for the reply,i got my problem solved..Thanx a lot