PDA

View Full Version : [CLOSED] How to get store's last applied options in Ext.NET 3



anup
Dec 23, 2014, 11:16 AM
Hi,

In previous versions of Ext.NET, in JavaScript I used to be able to get the full list of parameters sent to the server from the last read operation using something like this:



store.lastOptions.params || Ext.apply(store.autoLoad.params, store.additionalReadParams)


(store.additionalReadParams is the same as the myStoreParameters described in your post here: http://forums.ext.net/showthread.php?46591-CLOSED-Changing-store-read-parameters-in-JavaScript)

With a store requesting remote data via an AJAX Proxy I am finding that lastOptions doesn't have all the additional read parameters that were configured on the store. It has the page, sort, etc, but not a params property.

I might be able to get it implementing something very similar to buildReadParams on the store which is defined like this:



buildReadParams: function (operation) {
var prms = this.readParameters(operation),
params;

params = operation.getParams() || {};

if (prms.apply) {
Ext.apply(params, prms.apply);
}

if (prms.applyIf) {
Ext.applyIf(params, prms.applyIf);
}

operation.setParams(params);
}


I could then apply any additional parameters I might have to it.

However, I would need to send the right operation object (read, in my case) but I am not sure I should be doing that (the Sencha docs say we shouldn't normally need to be creating our own instances of these operations).

Any suggestions on an easy way to get the definitive list of parameters sent on the last request?

Thanks!

Daniil
Dec 23, 2014, 6:35 PM
Hi Anup,

Thank you for the question. I need more time to investigate it in details. I will post something once I finish.

Daniil
Dec 24, 2014, 10:16 AM
Hmm, not sure why a Store's lastOptions doesn't contain all the parameters. A defect or a lack in API or we overlook something? Well, anything is possible.

I can suggest the following solution.

Ext.define("MyOverrides", {
override: "Ext.data.proxy.Server",
buildRequest: function() {
var request = this.callParent(arguments);
this.lastParams = request.getParams();

return request;
}
});

When you can get all the previous request' parameters via

proxy.lastParams

Please let me know if it works well for you or not. I've tested with PageProxy and AjaxProxy, it appears to be working well.

anup
Dec 24, 2014, 11:54 AM
Many thanks for this.

Seems like a number of things have moved to the proxy, which is understandable.

But I think it may make things a bit cleaner... once I have finished the upgrading!

You can mark this as closed.