Author Topic: Get full URL that will be used including filtering and sorting  (Read 3376 times)

jlawler.scsi

  • Newbie
  • *
  • Posts: 7
    • View Profile
Hi, I'd like to implement an Excel export for the data in my grid that uses a remote data model including remote paging and filtering.

I don't want to have to pull all the data to the browser first and then render the Excel on the client side.

I've got a backend that will handle this for me, but I need to come up with the best method of getting the URL that pqGrid will use given the current filter and sorting state (minus the paging, since the Excel export will export *all* content, not just the current page) to pass to this Excel-generating backend.

I've tried to look for events etc. that might help with this and am coming up empty.  I of course case see in the console what URLs pqGrid uses when making the remote data calls, but is there some built in simple way for me to intercept that or predict what URL will be used?

Thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get full URL that will be used including filtering and sorting
« Reply #1 on: August 03, 2018, 12:51:59 pm »
Url for remote paging and filtering is same as mentioned in dataModel.url, few extra parameters are send along with url

https://paramquery.com/pro/tutorial#topic-remote-requests

Url for remote Excel export is specified in exportData method.

https://paramquery.com/pro/api#method-exportData

Complete data should be available to client side grid for export to Excel.

jlawler.scsi

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get full URL that will be used including filtering and sorting
« Reply #2 on: August 03, 2018, 08:09:20 pm »
Thanks for the reply.  I understand how the filter and sort data are JSON.stringify'd and added to the end of dataModel.url.

What I'm asking is: is there some API (or similarly supported/good) method for retrieving what that full URL will be (including the filter and sort data attached) for the given grid state (filter and sort columns).  Or, alternatively (and slightly less desirable): is there a way to retrieve what the *last* URL [with full pq_filter/_sort data] was?

What I'd really like is just the JSON.stringify'd pq_filter and pq_sort values (since I'll probably be using an alternate URL to do the Excel exports), but if I just get the entire dataModel.url + JSON.stringify(pq_filter) + JSON.stringify(pq_sort), that'd be good enough.

So is there any such method, or can you point me in the right direction to cobble something together like that myself?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get full URL that will be used including filtering and sorting
« Reply #3 on: August 14, 2018, 10:25:42 pm »
Full url can be accessed from settings.url in dataModel.beforeSend callback.

https://paramquery.com/pro/api#option-dataModel-beforeSend

If your requirement is to save / restore the states of the grid w.r.t filter,sort, etc.

then this example might be of interest to you: https://paramquery.com/pro/demos/grid_state