I'm using the following solution to change QueryTemplate on run-time:
protected override void OnLoad(EventArgs e) { if (this.AppManager != null) { if (this.AppManager.QueryGroups.ContainsKey(this.QueryGroupName) && this.AppManager.QueryGroups[this.QueryGroupName].DataProvider != null) { this.AppManager.QueryGroups[this.QueryGroupName].DataProvider.BeforeSerializeToClient += new BeforeSerializeToClientEventHandler(EnhanceQuery); } } base.OnLoad(e); } private void EnhanceQuery(object sender, BeforeSerializeToClientEventArgs e) { DataProviderScriptWebPart dataProvider = sender as DataProviderScriptWebPart; string currentQueryText = dataProvider.QueryTemplate; string token = "{LANGUAGE}"; if (currentQueryText.Contains(token)) { dataProvider.QueryTemplate = currentQueryText.Replace(token, GetCurrentLanguage()); } }
However, the problem is about the control display template with pagination AND the anonymous access.
For anonymous users, once the page loads, the programmatic ally additional query is performed correctly, but while clicking on "Next" button, the additional query is being ignored.
How to fix this problem?