I have to export the current grid contents into an excel format, so I pass the grid content back to server which then creates an excel file successfully but I am not able to open a save dialog on the user side. I am getting error as
“The data necessary to complete this operation is not yet available.”
Following is my code to send RPC request.
Why am I getting this error ?
To trigger file download, either just set window.location to the URL where the file will be downloaded (you can pass dat as URL params) or use the approach shown here of creating a form and calling submitForm().
Hello Isomorphic,
Thanks for the reply.
Now I am creating the form and submitting using submitForm().
I want to submit the listgrid data to the server to create excel report. I am using following code to submit which gives me null pointer exception at server side.
I am not able to pass this data to the server. Please guide me.
thanks
Do you really need to send the dataset from the client to server, or can you just retrieve it on the server instead?
If you need to send it, you need to figure out a way to encode it. Are you using the SmartClient server? If so, the best approach might in fact be to use the RPCManager (which can encode any JavaScript and deliver it to Java) combined with forcing the transport to “hiddenFrame” to allow downloading.
I was able to send the data to the server and successfully able to create excel report, but not able to display it on the user end. So as per your suggestion now I am using submitForm() approach. to submit. Let me know if there is any other work around to display the report using RPCManager.
As we just mentioned - you could send the data to the server via the RPCManager and use the rpcRequest.transport:“hiddenFrame” setting to avoid using transport:“xmlHttpRequest”, which is the default, and cannot download files.
It is opening the report just fine.
Now my question is how to send more data(for ex: I want to send search parameters and arraylist) to the server. Do I need to create a datasource? Please give me some feedback.
You can pass any JavaScript structure to the SmartClient Server and it will be translated to Java according to the rules in the docs for rpcRequest.data. So for example:
Please try to take a look at the docs before replying again -
So in the example we showed, expect getData() to be a Map - from there you simply use the Java Collections APIs (Map, List et al) to extract the data how you want it.