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. 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
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
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
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
You should include i18n/grid.locale-en.js before laoding jquery.jqGrid.min.js. See /jqgridwiki/doku.php?id=wiki:first_grid#html_file
You should of cause download from http://www.trirand.com/blog/?page_id=6
You can insert in your page all javascript files which you need to load (look inside of grid.loader.js) exactly how you load grid.loader.js file.
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”
Hi!
I use 'showlink'
I don't use Spring Framework myself, so I could not help you with any Spring MVC 3.0 examples. Some general solution is more common. For example in ASP.NET MVC solutions I
Hello!
The answer on your question depends a little how you interpret the “filtering”. If you want use some external controls (selects, checkboxes and so on on the same page where you have jqGrid) to filter your data I recommend you to read http://stackoverflow.com/questions/2928371/how-to-filter-the-jqgrid-data-not-using-the-built-in-search-filter-box/2928819#2928819
If you want to implement data filtering inside of jqGrid you can choose between serching with respect of “search” and reset of serching results with respect of “refresh” buttons of the /jqgridwiki/doku.php?id=wiki:navigator) action which provide the grid data or add three string parameters searchField, searchString, searchOper if you want to use simple searching feature. In all cases you will have to add WHERE to the SELECT statments which will be constructed in your program based on the values of the new parameters.
Probably other people post you more urls to the good full code examples which you could use.
Best regards
Oleg
Do you tried with dataFilter event of jQuery.ajax? You can set it with respect of ajaxGridOptions option. In general I could agree with you that
You can define search: false for any column in the colModel (see /jqgridwiki/doku.php?id=wiki:colmodel_options). This will disables searching on that column. In general it seems me that columns with hidden: true, will not be displayed in the searching dialog if you
Hi Taker!
The datatype “jsonstring” is a form of holding of the local data in jqGrid where you load all the data in once. So having the number of records or the number of pages which not corresponds the data from the JSON string has no
Hi Mark!
It seems to my Tony misunderstood your question. I hope if you define sortable parameter as an object instead of a boolean you can solve your problem. For example
sortable: {
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top