JQ Grid sorting integers - sorting

Can anyone please tell me how to sort integers/numbers in JQ grid.
the regular sorting gives a distorted order.
Hi i got it all done when i use loadonce=true and sorttype = 'int'. But i cant use loadonce, since i need to reload the grid several times for my purpose.
Can anyone say how to do it without using loadonce??
Thanks,
Devan

If you use datatype:'json' or datatype:'xml', then the server is responsible for the data sorting. The sidx and the sord parameters which will be send as the part of request to the server describes which sorting should use the server.
If you want to implement client side sorting and paging of data you can use loadonce:true jqGrid parameter. In the case you should define sorttype property (having default value 'text') which describes the data type from the column. After the first data loading the datatype of the jqGrid will be automatically changed to 'local' and the sorting, paging and filtering/searching of data will be implemented locally by jqGrid itself.

Related

Free JqGrid: Sort DESC on first click

I'm using Free JqGrid and I have an issue with sorting the columns. I use a remote data in my setup. I want the grid to load default without no sorting at all, but when the user clicks any of the sortable columns I want it to sort DESC first instead of ASC (which it will always do). I'd also like the (default) sorting icons to point in this direction.
Can anyone point me in the right direction?
If you use remote datatype (datatype: "json" or datatype: "xml") then the data will be displayed in the grid in the order in which it will be returned from the server. If your server sort the data based on the request from jqGrid then you need verify that you use no initial sortname parameter.
About your second problem. It's enough to add firstsortorder: "desc" property to the column definition to have DESC sort order on the first click of the user on the column header.

Sorting on hidden data

Is it possible to have data in a Handsontable sorted by a field which is not displayed? I have a grid of data which I would like to display that contains a column called "sortOrder", but I don't want to display this.
The sorting needs to be done client side because events are coming in over web sockets and need to be reflected in the table.
If you're not showing the column then I assume you're not expecting the user to be able to manually sort by this hidden column. Therefore, why don't you simply sort your data array with native JS? At any point during execution you could have a function which sorts by this hidden column and then just don't render this in your Handson definition.
So yes, the answer is it is possible. The not showing of a column is as simple as defining the columns option and not including a column for this hidden value.

How to: jqGrid dependent select box display values in rows

I have implemented dependent dropdowns in jqGrid (similar to this example). The row data returned has values as well as display values. How can I show display values on grid rows? At grid initialization time I do not have list of values for dependent dropdowns, they get loaded from the server when user selects value from other dropdown. formatter: 'select' helps when I know the values of dependent dropdown but I am not sure how to use it when the values are loaded dynamically.
In case of loading the data from the server you need just set editoptions.value or formatoptions.value before formatter: "select" start to process the data. You can use beforeProcessing callback for example. It will be called at the moment which you need. You can place the information with editoptions.value in userdata part of the server response or in any other place. The data parameter (the first parameter) of beforeProcessing callback contains all the data from the server response. So you can easy get the required data and to use setColProp for example to change the options used by formatter: "select". I recommend you to read the answer for the corresponding code example.

Sort whole store in paging grid extjs 4

in my app I have a paging grid and when I click on a column to sort it, it sorts only the current page. How can I sort the whole store and then split it in pages?
Can I override the sort function to send extra params to the php script that convert my database into a json store and edit the query adding a ORDER BY extraparam?
You need to enable remoteSort by setting remoteSort: true on the store instance. See remoteSort
You will now receive the sorting as you receive the paging as own params-list and can include it into your query.

Filter Toolbar without loadonce:true?

I am using jqgrid, with filter toolbar(column) option...The total data is around 10,000...So it seems to be some delay in initial loading as the config is set to loadonce:true;
Any way to implement the filter column feature with loadonce:false ?
Because the data loading delay is okay with loadonce:false. If I get a chance to add column filter with loadonce:false, this will work perfectly...
If you has about 10,000 rows it is of course better to implement server side data paging, sorting and filtering. I recommend you to use filterToolbar with the parameter stringResult:true if you not already use it. In the case jqGrid will send to the server filters parameter in the same format like advanced searching as do. So you will need implement on the server side the method which use following input parameter from jqGrid:
sidx and sord parameters define the sort order of the data. The informations specify ORDER BY in the corresponding SELECT statement.
if _search parameter is true, then the next parameter filters gives additional information which construct the WHERE part of the corresponding SELECT statement.
page and rows parameters define which page of the data previously sorted and filtered should be returned.
The exact implementation is depend on the language and technology which you use on the server and of course which database server and which interface to the database you use.

Resources