Ticket T517262
Visible to All Users

Web - How to preserve the FullTextSearch Action filter after opening details for a record and returning back to ListView

created 8 years ago

Hello,

I am working in a Web xaf application, where I have a listview where I show some products, and a detail view to access to more information of the product. If I apply a filter using the text searcher and I enter to a detail of one of the filtered products, when I go back to the list view the text filter has been removed.

Is it possible to keep this filter going back from the detail view?

Thank you.

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello Joan,

Sure, that is possible using a relatively simple Controller:

C#
using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.Model; using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp.Web.SystemModule; namespace MainDemo.Module.Web.Controllers { public class WebPreserveFullTextSearchResultsListViewController : ViewController<ListView>, IModelExtender { private FilterController filterController = null; protected override void OnActivated() { base.OnActivated(); string parameter = ((IModelListViewFullTextSearch)View.Model).FullTextSearchParameter; filterController = Frame.GetController<FilterController>(); if(filterController != null) { if(!String.IsNullOrEmpty(parameter)) { filterController.FullTextFilterAction.DoExecute(parameter); } filterController.FullTextFilterAction.Execute += FullTextFilterAction_Execute; } } protected override void OnDeactivated() { if(filterController != null) { filterController.FullTextFilterAction.Execute -= FullTextFilterAction_Execute; } base.OnDeactivated(); } void FullTextFilterAction_Execute(object sender, ParametrizedActionExecuteEventArgs e) { ((IModelListViewFullTextSearch)View.Model).FullTextSearchParameter = (String)e.ParameterCurrentValue; } public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) { extenders.Add(typeof(IModelListViewWeb), typeof(IModelListViewFullTextSearch)); } } public interface IModelListViewFullTextSearch { string FullTextSearchParameter { get; set; } } }
Visual Basic
Imports System Imports DevExpress.ExpressApp Imports DevExpress.ExpressApp.Actions Imports DevExpress.ExpressApp.Model Imports DevExpress.ExpressApp.SystemModule Imports DevExpress.ExpressApp.Web.SystemModule Namespace MainDemo.Module.Web.Controllers Public Class WebPreserveFullTextSearchResultsListViewController Inherits ViewController(Of ListView) Implements IModelExtender Private filterController As FilterController = Nothing Protected Overrides Sub OnActivated() MyBase.OnActivated() Dim parameter As String = DirectCast(View.Model, IModelListViewFullTextSearch).FullTextSearchParameter filterController = Frame.GetController(Of FilterController)() If filterController IsNot Nothing Then If Not String.IsNullOrEmpty(parameter) Then filterController.FullTextFilterAction.DoExecute(parameter) End If AddHandler filterController.FullTextFilterAction.Execute, AddressOf FullTextFilterAction_Execute End If End Sub Protected Overrides Sub OnDeactivated() If filterController IsNot Nothing Then RemoveHandler filterController.FullTextFilterAction.Execute, AddressOf FullTextFilterAction_Execute End If MyBase.OnDeactivated() End Sub Private Sub FullTextFilterAction_Execute(ByVal sender As Object, ByVal e As ParametrizedActionExecuteEventArgs) DirectCast(View.Model, IModelListViewFullTextSearch).FullTextSearchParameter = CStr(e.ParameterCurrentValue) End Sub Public Sub ExtendModelInterfaces(ByVal extenders As ModelInterfaceExtenders) extenders.Add(GetType(IModelListViewWeb), GetType(IModelListViewFullTextSearch)) End Sub End Class Public Interface IModelListViewFullTextSearch Property FullTextSearchParameter() As String End Interface End Namespace

Check out the following concepts to learn more about this implementation:
    Concepts > Extend Functionality > Customize Controllers and Actions
    DevExpress.ExpressApp.SystemModule > FilterController
    Task-Based Help > How to: Extend the Application Model

I am looking forward to hearing from you.

    Show previous comments (1)
    Dennis Garavsky (DevExpress) 8 years ago

      You're always welcome, Joan!

      D D
      Daniel Raúl Vanzo 8 years ago

        Any way to have the Vb.net code? I tried to convert it but without luck…

        Daniel

        Dennis Garavsky (DevExpress) 8 years ago

          @Daniel: I've added VB.NET code. BTW, you can always use free or paid converter tools available on the Web. I hope you find this tip helpful for the future, because the majority of our SC tickets are submitted by C# users.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.