Hello,
It seems to me you do not have read carefully what Will recommend you.
Your code will work if you do this after calling the grid:
|
1 2 3 4 |
... $("#jqGrid").jqGrid('setGridParam', {postData : {}}); ... |
Note that using grid complette event is not recommended since this is lunched after every search, sort and etc.
Here is the modified code which use the postData as string and the local search is working as well.
This way – “You have the cake and it it too”
Enjoy
Best Regards
Hello Trevor,
As far as I can remember we have a similar example – search upon loading.
This can be found here.
The idea is simple – you should tell the script to perform the search. This is done with serch set to true.
In your example code you can try this:
|
1 2 3 4 |
jQuery('#grid').jqGrid('setGridParam',{ postData: obj['postdata'], search : true }).trigger("reloadGrid"); |
Best Regards,
Hello again,
We need to fix the problem where the search results should be expended in case if they are not
Regards,
Hello,
First of all thank you for look on this and perform a testing.
When downloading from github you will need to replace only 3 files
jquery.jqGrid.min.js
ui.jqgrid.css (or ui.jqgrid-bootstrap.css if Bootstrap is used)
the appropriate language file.
For testing purpose you can replace the minified jquery.jqGrid.min.js with the sourcecode jquery.jqGrid.js
I can’t imagine how can I order a cake and can’t it.!
This was a small chalnge for me, but actually the idea is to change thed data type to local before searching and put it back after the search is done. I have implemented this using the two events beforeSearch and afterSearch (suppose you use filter toolbar)
Here is the demo, which I have prepared for this purpose: Link to demo
In the demo I use beforeRequest to change the json data file – so this is not connected with our problem.
Unfortunately I can not reproduce the problem when we initially serch and after this we perform a sort. It will be very good if you can provide a simple test case with data.
Please let us know if there is a problem.
Kind Regards,
Hello,
We have implemented your suggestion and we find it very useful.
The updated code is in GitHub. It is in beta and needs to be refined.
If you want you can get it and test it.
Any other recommendation is welcome.
Best Regards,
Hello Kris,
Thank you very much for the recommendation.
We will take this into account. I suppose you mean our desktop jqGrid.
Please note, that we have similar feature using iScroll property in our mobile version:
You can check the exmple here.
Kind Regards,
Hello,
You almost have done it, but let see what you have do.
The grid settings are fine, but when the datatype initially is local you pass the rows form obj_initial_data – where is the other info so that the grid know what to do?
Actually if the datatype is local this info is not used, so we need to tell the grid something with parameters, but without to make reload of grid since this does not have sense (as you say)
Using gridComplete is not recommended. The most users use it, but this should be done only when you need to do something after the data is loaded. If you have to do only one action after the grid is loaded this event is not recommended.
The good way is just to use the command after the grid is called and nothing more. Using setTimeout will ensure that our commands will exceute once after the grid loaded.
Lucky we have a method which does not reload the grid, but change the pager settings and nothing more. This method is called updatepager. Bellow is the code which works. Note that the url is set in the grid initially, but you can change it in setGridParam too.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
var obj_initial_data = { "page": 1, "total": 2, "records": 9, "rows": [ { "id": "1", "make":"VW", "model":"Bus", "year":"1976", "color":"green" }, { "id": "2", "make":"Ford", "model":"F150", "year":"1984", "color":"brown" }, { "id": "3", "make":"Toyota", "model":"Camry", "year":"1989", "color":"maroon" }, { "id": "4", "make":"VW", "model":"Passat", "year":"2003", "color":"blue" }, { "id": "5", "make":"Toyota", "model":"Tacoma", "year":"1997", "color":"silver" } ]}; $(document).ready(function () { $("#tbl_test").jqGrid({ colNames: ['id', 'Make', 'Model', 'Year', 'Color'], colModel: [ {name: 'id', index: 'id', hidden:true}, {name: 'make', index: 'make'}, {name: 'model', index: 'model'}, {name: 'year', index: 'year'}, {name: 'color', index: 'color'} ], url: '<span class="crayon-s">http://cdn.octavient.net/jqgrid/test_server.aspx</span>', pager: '#pgr_test', pgbuttons: true, datatype: 'local', data: obj_initial_data.rows, localReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false }, gridview: true, height: 180, //loadonce: true, autowidth:true, rowNum: 5, viewrecords: true }); setTimeout(function(){ var grid = $("#tbl_test"); grid.jqGrid('setGridParam', { records: obj_initial_data.records, lastpage: obj_initial_data.total, datatype: 'json'}); grid[0].updatepager(false,true); },100); }); |
One additional note – you use 4.5.2 version which is old and is no more supported.
Enjoy
Kind Regards,
Tony
Hello Kris,
I have added your additions in the article here
Thank you very much for you contribution.
Kind Regards,
Hello Kris,
That are great additions!
Could you please allow us to include these additions in the article and the example in the demo distributed with the package.
Thank you very much for sharing your additions!
Kind Regards,
Hello,
It depends on what you return from server. By example you should return the total number of records too. As PHP example you can look here
Kind Regards,
Hello,
I highly recommend you to look at our demo page here: http://www.guriddo.net/demo/guriddojs
In this demo you will find this example: http://www.guriddo.net/demo/guriddojs/integrations/column_chooser/index.html
Willy have point you to where to look at the texts that can be changed (language file in this case property cap.
So in your code you should use option property caption in column chooser and not title.
Kind Regards,
Hello,
Any feedback on this problem would be greatly appreciated.
Thank you.
Kind Regards,
Hello again,
The comment in the knowledgebase needs to be approved. I just have do this.
It seems that this article will be very popular.
Kind Regards
Hello,
If I understand right you want a functionality similar to datepicker.
Actually it is not so easy. A possible approach is to use the focus/blur events on element, but I think this will make some trouble since the grid needs to focus a search fields.
It is really difficult using the current implementation of the grid, but not impossible. I will think about this, but do not promise that it can be done quick.
Kind Regards,
P.S. IMHO using jQuery autocompleter is another good solution too. In the same demo there is a use of autocompleter.
Hello,
We have added in our Knowledgebase the article explaining how to do pop up selection.
Enjoy.
Kind Regards,
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top