Home › Forums › Guriddo jqGrid JS › Help › Pager not working (for me). Where am I doing wrong?
I don't understand why you use datatype as function to load JSON data? jqGrid has already support for JSON data. You should just use datatype: “json”
OlegK said:
I don't understand why you use datatype as function to load JSON data? jqGrid has already support for JSON data. You should just use datatype: “json”
I don't like if sombody be not polite to me. Jokes like “You should ask somewhere else if you want help…” I find not funny.
Your code not works because it has errors (at least 2). Good luck in searching of errors. Bye bye.
Oleg
OlegK said:
I don't like if sombody be not polite to me. Jokes like “You should ask somewhere else if you want help…” I find not funny.
Your code not works because it has errors (at least 2). Good luck in searching of errors. Bye bye.
Oleg
Hello Oleg,
You say that I have not been polite with you….. I dont believe that you're right
and invite you to read again your first answer to see if you have been polite with me.
I have clearly stated in my first post that it was my first usage of the jqGrid package
and I have asked why the pager did not worked correctly. Your answer has told me:
Dear verorange,
Dear OlegK,
Please let the dispute go in professional skills and not on personal one.
I know that sometime this go out from control, but I hope that this is
a temporary.
We actually have this forum to help each other and not
OK I agree, that as I read till the end your post I forgot how you start the mail. So I forgot that you are beginner in jqGrid. Moreover it was 3:00 at night.
If your server really produce the JSON data like you wrote before you should change declaration of jsonReader to
Hello,
> OK I agree, that as I read till the end your post I forgot how you start the mail.
> So I forgot that you are beginner in jqGrid. Moreover it was 3:00 at night.
Ok. No problem for me.
Verorange, Oleg
Thanks.
Kind Regards
I am sure, that your problem is on the server side. If I save the JSON data which you posted to a file verorange.txt, change mtype: “POST” to mtype: “GET” one can test the grid without any active server components. How you can see here
This is very strange.
I have tried to change the mtype and the url properties and everything works as expected.
I have also tried to use a different version of the jsonReader as your example suggest but it
OK. Now I understand where you have the problem. You use Newtonsoft.Json to serialize the data, but your web service don't know this and try to serialize the data one more time. So you have probably twice serialized string. If the oririnal string was My string. JSON seirialized string will be “My string“. If the original string was “MyString” then serialized version will have escaped quotas: “MyString”. So after deserialization of a string you have allways the type string in Javascript instead of an object.
If you will just use standard Microsoft serialization you need only include
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json)]
before the web method GetProvinces and return just an instance of the class JqGridData. Web service will serialize the data yourself, but include all data inside the property “d”: {d:{..}}.
I uploaded a working test program which full simulate your first data under http://www.ok-soft-gmbh.com/jqGrid/WebServicesPostToJqGrid.zip.
If you do need to use a custon JSON serialization like Newtonsoft.Json I should better use WCF instead of ASMX. The code is exactly so simple like ASMX, but you have much more flefibility. If your WCF web method return Stream or Message type, than you can return any type of data: any custom serialized JSON data, JPEG and so on. You can also stream the data if needed.
See http://msdn.microsoft.com/en-us/library/ms789010.aspx, http://stackoverflow.com/questions/3078397/returning-raw-json-string-in-wcf/3079326#3079326 and http://stackoverflow.com/questions/3118504/how-to-set-json-net-as-the-default-serializer-for-wcf-rest-service/3131413#3131413 for more information.
Regards
Oleg
Finally we got through!!!!
Now everything works fine and very very good!!!!
One more question Oleg: what if I have an entity with 10 fields but I want to show only a subset of them inside the jqGrid?
Do I have to code a wrapper class or can I configure jqGrid to show/hide the fields that I dont need?
Thanks again for the help you have given to me.
Regards
verorange
In general the less data you send over the wire the better. So instead of array of strings like
{“ID”:1,”Sigla”:”AG”,”Name”:”Agrigento”,”Region”:”Sicilia”}
which are elements of rows array and every row represent an object jqGridRecord. It can be better
[1,”AG”,”Agrigento”,”Sicilia”]
as representation of List or string[]. Then you can use more simple jsonReader (without repeatitems: false). It seems to me you can easy implement such data representation. A discussion about this and the coresponding example you can find here
Best regards
Oleg
Ok for this!
But the meaning of my question was different. Suppose that I dont want to show the field ID and the field Region in the grid.
Do I have to code a wrapper class that dont send those fiedls or I can modify the config to not show them?
OK I clear in other words.
So you can convert data entity directly in the instance of the PagedList classes. Sometimes usage of anonymous data types can be helpful.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top