Home › Forums › Guriddo jqGrid JS › Help › Sortable, reloadgrid and loadonce=true problem
Hi,
I have a problem: I need sortable columms but I need too that with the push of one button the grid will reload the data that's comming from server, but if I put reloadOnce=”true” the call to the
$(
“#listCC”).trigger(“reloadGrid”);
don't reload the data from server and the data of the screen is out of date.
If I put reloadOnce=”false” then it work correctly, but the columns are not sortable.
is there any solution?
thanks a lot.
Josep Escofet
Josep,
Check your logic again. To sort this way you need to pass additional parameters to sort. Example:
$(“#mygrid”).setGridParam({sortname:'myname',sortorder:'asc'}).trigger(“reloadGreid)
Also in module inlineedit there is a very useful method sortGrid(colname,reload)
where the colname is the colname and reload is boolean which tells if the grid should be reloaded.
Regards
Tony
Hi Tony,
I have tested your solutions but it not work for me.
When It is default option loadonce:false, every time that I click in one
column it is calling to server and asking the file.xml of the rows, the server charges the file correctly but it is not ordered.
When I put loadOnce:true , every time I click the column the list is displayed ordered, but not is calling to server for refreshing data. I have tryed too
put loadOnce:true and when the user push a button :
$(”#mygrid”).setGridParam({loadonce:'false'}).trigger(”reloadGrid”)
but it is not calling to the server for refreshing data.
I send you the jQgrid defiition and the xml file. I dont understand what is happening.
jqgrid definition:
jQuery(document).ready(function(){
My simple question is?
What you have? already constructed xml file or a data constructed from
a SQL query?
This data is a sample constructed from server, Struts action populates a
List and the list is putted on session and after there is a jsp file that renders
this list as xml file. The original data comes from database thru sql, but
too it is putted on list and after there is a jsp file that renders this data.
An example with original data is here :
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
1 |
|
1 |
13 |
|
1 |
13 |
|
1 |
|
1 |
|
1 |
8 |
|
1 |
*CIAL.TEXTIL ARBITEX/3 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
45103397577 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
9 |
|
1 |
*CIAL.TEXTIL ARBITEX/4 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
12 |
|
1 |
*CIAL.TEXTIL ARBITEX/7 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
13 |
|
1 |
*CIAL.TEXTIL ARBITEX/8 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
14 |
|
1 |
*CIAL.TEXTIL ARBITEX/10 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
45103397577 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
21 |
|
1 |
*CIAL.TEXTIL ARBITEX/12 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
24 |
|
1 |
*CIAL.TEXTIL ARBITEX/14 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
28 |
|
1 |
*CIAL.TEXTIL ARBITEX/1 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
29 |
|
1 |
*CIAL.TEXTIL ARBITEX/5 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
30 |
|
1 |
*CIAL.TEXTIL ARBITEX/6 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
35 |
|
1 |
*CIAL.TEXTIL ARBITEX/2 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
37 |
|
1 |
*CIAL.TEXTIL ARBITEX/11 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
38 |
|
1 |
*CIAL.TEXTIL ARBITEX/16 PROD.ACCIDENTES |
|
1 |
|
1 |
01000000128 |
|
1 |
01000000128 |
|
1 |
45103397577 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
You should pass in your SQL a ORDER BY cluse to sort have effect.
Example (php code)
$sorcol = $_GET['sortname']; // this is taken from grid and then
$sortorder = $_GET['sortorder'];
$SQL = “SELECT * FROM mytable ORDER BY “.$sortcol.” “.$sortorder;
Sorry there is mistake
the right is:
$sortname = $_GET['sidx'];
$sortorder = $_GET['sord'];
thanks Tony,
But if you put loadonce=true the data is sorted when you click some col,
is it done for the javascript in the client side?
Josep Esofet
loadonce parameter load the data from server only once and then the processing is at client side – i.e. the datatype is set automatically to clientSide
Refer to docs for more info
Regards
Tony
Thanks tony,
I have made the sort at the server side, and now it is working perfectly.
thanks a lot.
Josep Escofet
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top