Hi!
I try add parameter to query in controller by next way:
HttpContext.Current.Response.Redirect((string.Format("DefaultVertical.aspx#ShortcutViewID=SaleItem_ListView_PurchaseSummary&ClientOrderID={0}&ShortcutObjectClassName=Databutikken.ERP.Module.BusinessObjects.SaleItem", currentOrder.OrderId)));
I want filtering collection in ListView by this parameter
But when the page download, parameter is not present in query string, and I can not filtering collection
Passing parameter in QueryString
Answers
It does not seem to be related to DevExpress controls but here's the answer anyway: replace the # symbol with ?.
Also you might want to encode your URL with HttpServerUtility.UrlEncode first.
Hello Roman,
You cannot easily process Get parameters in a controller, because the query string is modified by XAF HTTP handler. If you wish to pass an additional information to the XAF view outside the XAF application, add this information to the ViewShortcut (e.g. add the ShortcutClientOrderID parameter to the query string) and get it in the XafApplication.CustomProcessShortcut event handler.
If you need to pass something to a view inside the XAF application, do not use the Redirect method. Instead of this, show view via the ShowViewStrategy.ShowView method, as shown in the How to invoke a View without using Actions or from a place that is different from the Controller context article.
When the browser's Refresh button is clicked, the ListView is restored from the shortcut, and since the shortcut does not contain the collection source's criteria, the latter is lost. To solve this problem, store criteria somewhere, e.g. in cookies or in the view's model, and restore it when the view is shown. The easiest way to do this is to use the model's Criteria property - in this case it is be required to restore criteria manually. To avoid changing the default Book_ListView, create a copy and use it as the model of the shown view. Here is an example:
C#IObjectSpace os = Application.CreateObjectSpace();
CollectionSourceBase cs = Application.CreateCollectionSource(os, typeof(Solution1.Module.BusinessObjects.Book), "Book_ListView_Copy");
IModelListView listViewModel = (IModelListView)Application.Model.Views["Book_ListView_Copy"];
listViewModel.Criteria = "Author_ID.ID = " + author.ID.ToString();
e.ShowViewParameters.CreatedView = Application.CreateListView(listViewModel, cs, true);