0

I am using ExtJs 4.1 grid. I have enabled the remoteSort in the store & enabled sortable property for the columns. Everytime I sort\click on column header, a call is made to the server with sort params being passed in the query string.

I want to know if there is a client side event, which gets fired before call is made to the server? I want to check certain condition and based on that I may cancel the call to the server.

Please suggest.

SharpCoder
  • 18,279
  • 43
  • 153
  • 249

1 Answers1

1

There is a sortChange event that gets fired whenever you sort the grid.

See the documentation here.

I have created a fiddle demo that logs to the console every time the grid is sorted. It should help.

If that doesn't work you'd likely need to attach to the stores beforeSort or the refresh event.

EDIT: As the beforeSort event is not available for ExtJs Version 4, you'd likely need to listen to the refresh event:

Refresh: Fires when the data cache has changed in a bulk manner (e.g., it has been sorted, filtered, etc.) and a widget that is using this Store as a Record cache should refresh its view.

Scriptable
  • 19,402
  • 5
  • 56
  • 72
  • I tried that but its getting fired after the server side call is made !!!! Either the call is been made simultaneously (server side and client side together) or server side call is made first. I want to change the data that we are posting to the server when user sorts any column. – SharpCoder Feb 24 '15 at 13:58
  • Updated again :) Sorry, I forgot your using ExtJs 4 – Scriptable Feb 24 '15 at 14:19
  • stores refresh event is called after the data is refrehsed. That means on sort, app has made call to the server and server has returned data. I want to edit the data I am posting (to the server on the sort event) on the client side before i sent it to the server – SharpCoder Feb 24 '15 at 14:28
  • `beforesync` should catch that – Scriptable Feb 24 '15 at 14:30
  • @Sciptable: That would not help. When I create the grid system post some data (input) to the server. Based on this input-data, server returns some output. Now when user sorts a column, be default same input-data is posted to the server along with sort params (which goes as query string). What I want is, I want to edit the input-data which I grid is automatically posting to the server. For that I need to find a client side event which will allow me to edit input data. Which later I can update using `grid.getStore().proxy.msgBody` property & then this data will go to the server. – SharpCoder Feb 24 '15 at 14:40
  • I see what you mean, Your likely going to need a more complex solution then, let me look into it. So you want to edit the grid's data *before* its sent back to the server to update yeah? – Scriptable Feb 24 '15 at 14:55
  • Thats correct. I want to edit the data that is been sent to the server. – SharpCoder Feb 25 '15 at 07:40