Nov 12, 2014, 2:43 PM
[CLOSED] Changing store read parameters in JavaScript
Hi,
This post was close to what I was looking for:
http://forums.ext.net/showthread.php...pt-before-load
But my scenario is slightly different.
I have, for example, a category tree and a grid. The grid, also has a search box in a toolbar. Furthermore, there are various buttons and dialogs users can use to build complex search requests.
In Ext.NET 1 I used to update baseParams using store.setBaseParam() with various parameters, such as the id of the category, the search term, or other search criteria our dialogs help to build.
setBaseParam is kind of replaced with store.proxy.extraParams, and I think I can use that for my needs. However, as I understand, and per a different thread we discussed, extraParams will also be sent for update requests, not just read requests.
I would ideally like to just update the read parameters, but I see that Ext.NET generates a function that returns an object literal of the initial parameters I defined. Some of these are ones I want to update, and other parts of the grid UI may create new parameters to add to this set of read parameters as they are not always needed initially.
Am I missing a way to update only the read parameters?
My initial thoughts were along the following lines:
Currently Ext.NET will generate a readParameters function on Store similar to this:
Now, if a user types a search, I want to add a "search" property. If they update the category they are looking at, I have the category id so I just want to update the "selectedCategoryId" property, etc.
Does readParameters need to be a function? It is not doing anything with the operation parameter. It seems like it could just be the object literal:
Is that a possibility or have I misunderstood something? And if so, is there a better/alternative way I should approach this?
Thanks!
This post was close to what I was looking for:
http://forums.ext.net/showthread.php...pt-before-load
But my scenario is slightly different.
I have, for example, a category tree and a grid. The grid, also has a search box in a toolbar. Furthermore, there are various buttons and dialogs users can use to build complex search requests.
In Ext.NET 1 I used to update baseParams using store.setBaseParam() with various parameters, such as the id of the category, the search term, or other search criteria our dialogs help to build.
setBaseParam is kind of replaced with store.proxy.extraParams, and I think I can use that for my needs. However, as I understand, and per a different thread we discussed, extraParams will also be sent for update requests, not just read requests.
I would ideally like to just update the read parameters, but I see that Ext.NET generates a function that returns an object literal of the initial parameters I defined. Some of these are ones I want to update, and other parts of the grid UI may create new parameters to add to this set of read parameters as they are not always needed initially.
Am I missing a way to update only the read parameters?
My initial thoughts were along the following lines:
Currently Ext.NET will generate a readParameters function on Store similar to this:
readParameters : function (operation) {
return {
apply : {
"selectedCategoryId" : 13,
"selectedCategoryActivityId" : 2,
"searchActivityId" : 2,
"viewActivityId" : 2,
"view" : "gv_ProductInformation",
"includedCategoryIds" : "",
"excludedCategoryIds" : "",
"includedDocumentIds" : "",
"excludedDocumentIds" : ""
}
};
}
Yes, quite horrendous looking, but our search is complex :) And there are many more parameters I have removed here!Now, if a user types a search, I want to add a "search" property. If they update the category they are looking at, I have the category id so I just want to update the "selectedCategoryId" property, etc.
Does readParameters need to be a function? It is not doing anything with the operation parameter. It seems like it could just be the object literal:
readParameters : {
apply : {
"documentType" : "ppm:Product",
"useAsRootConceptFilter" : false,
"relationshipId" : "",
"parentExternalId" : "",
"parentActivityId" : 0,
"selectedCategoryId" : 13,
"selectedCategoryActivityId" : 2,
"searchActivityId" : 2,
"viewActivityId" : 2,
"view" : "gv_ProductInformation",
"includedCategoryIds" : "",
"excludedCategoryIds" : "",
"includedDocumentIds" : "",
"excludedDocumentIds" : "",
"useIncludedDocumentsAsManualOrder" : false,
"documentType" : "ppm:Product",
"processMessages" : true
}
}
}
Then, any time I need to interact with the store, I can get the proxy and simply update the readParameters, using something like store.readParameters.search = "my search term";Is that a possibility or have I misunderstood something? And if so, is there a better/alternative way I should approach this?
Thanks!
Last edited by Daniil; Nov 18, 2014 at 5:24 PM.
Reason: [CLOSED]