Sort whole store in paging grid extjs 4 - sorting

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.

Related

Should i send filter with AJAX or filter an array?

i'm implementing a web page that shows certain rows fetched from a database.
At loading, i make an AJAX request to fetch the rows in a certain range of time(the initial call will take today's rows), and save them in a global variable(e.g "rows").
I have two text field to set the starting and the ending point of my research, and every time i change the value of those text-fields, i make another call to the db to get the new data and update global "rows" variable.
My question is: if i have different text-field filters and sort options that apply filters and sort to the fetched rows, should i make another request to the db(with the selected filters/sort) and let the db handles the filter/sort, or should i apply the filters/sort directly the global "rows" variable?
Of course i think the db filtering and sorting would be more efficient, but the number of rows shouldn't be more than 100, max 200 rows, and i was wondering if it would be worth it to make another AJAX request just for filter the result.
Thank you very much in advance.
have you try with datatables server side??
https://datatables.net/examples/data_sources/server_side.html
I think is a good options for you and very easy to implement

KendoUI filters and paging functionality - How they work with large JSON data

I have 100,000 records right now (will grow in future). I have JSON api call (remote URL, however, within same server) to get those records. If I use KendoUI with paging turned on (say 50 per page), will KendoUI datasource going to fetch all those records and bring them into client and apply paging? Or is it something I need to pass to the server (page size) to be able to only get only needed data for display? If I need to pass, do I have to write custom data source query methods?
Same question goes for using filter input boxes in toolbar within KendoUI.
There are two (efficient) ways of loading that amount of data:
Setting serverPaging to true in the DataSourcedefinition.
Using serverPaging plyst (as #bobosov534 and #gitsitgo suggests) virtual scrolling.
In the both you receive in the server tow parameters: top indicating the number of records to retrieve (what you have defined as pageSize) and skip for the number of records to ignore (no skip means the first top records).
The difference is that int the first you see a pagination bar in the bottom of the grid and in the second you see additional records as you scroll down.
In DataSource.serverPaging you find detailed information on the fields sent to the server for managing pagination.

TableSorter too many records

I have already implemented TableSorter in my project. Now the problem is that in some case I need many records more than thousand. And TableSorter plugin does pagination client side through ajax. I want it to do server-side pagination + I want to sort on a single page, not on whole data. i.e. If there are 10 records on a single page of TableSorter, sorting must be done on that single Page(on that 10 records only). I can't change to another table plugin. What should I do? My data is coming from model.
For the pager ajax demo, I had to change the serverSideSorting option manually to make it sort the current table contents. Maybe that will also work for you? Try including this code:
$('table').bind('pagerInitialized', function(e, c){
// allow current content sorting; this variable is automatically
// set to true when ajax is initialized
this.config.serverSideSorting = false;
});

JQ Grid sorting integers

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.

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