We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Restore filter settings on page load

Thread ID:

Created:

Updated:

Platform:

Replies:

114396 Nov 18,2013 09:52 AM Mar 5,2018 11:26 AM ASP.NET MVC (Classic) 3
loading
Tags: Grid
Mirko Pozzetti
Asked On November 18, 2013 09:52 AM

Hello,
I would like to restore the saved filters of the grid during the last visit on the page. I would like to know how to save and restore the settings on server side.
Thank you very much for your help,
Mirko


Prabhu Sarvesan [Syncfusion]
Replied On November 19, 2013 07:05 AM

Hi Mirko,

Thanks for your interest in Syncfusion product.

We would like to let you know that your requirement “Restore filter settings on page load” has been achieved on the server side. To achieve your requirement use Filter Descriptor values to restore filter settings on page load. To maintain paging, Sorting and other grid functionality use session concepts. The code snippets is shown below,

Code Snippet:

[CS]

public class HomeController : Controller

    {

   public ActionResult Index()

        {

            if (Session["Args"] != null)

            {

                List<AutoFormatting> data1 = new List<AutoFormatting>();

                var arg = (List<FilterDescriptor>)Session["Args"];

                for (int i = 0; i < arg.Count; i++)

                {

                    var col = arg[i].ColumnName;

                    var val = arg[i].Value.ToString();

List<AutoFormatting> data =                                  (List<AutoFormatting>)AutoformatRepository.GetData();

                    foreach(var dat in data)

                    {

 if ( dat.Currency.ToString()==val.ToString() || dat.Dates.ToString() ==  val.ToString() || dat.Number.ToString() == val.ToString() || dat.Telephone.ToString() == val.ToString())

                        {

                            data1.Add(dat);

                        }

                    }     

                }

                Session["Data"] = data1;

                return View(data1);

            }

            var data2 = AutoformatRepository.GetData();

            return View(data2);

        } 

 

        [AcceptVerbs(HttpVerbs.Post)]

        public ActionResult Index(PagingParams args)

        {

            if (args.FilterDescriptors.Count != 0)

            {

                Session["Args"] = args.FilterDescriptors;

            }

            if (Session["Data"] != null)

            {

                List<AutoFormatting> data1 = (List<AutoFormatting>)Session["Data"];

                Session["Data"] = data1;

                return data1.GridActions<AutoFormatting>();

            }

            IEnumerable data = AutoformatRepository.GetData();

            return data.GridActions<AutoFormatting>();

 

        }

}

 

For your convenience we have created a sample and the same can be download from the below attachment.

Please let us know if you need any further assistance.

Regards,

Prabhu Sarvesan



SampleGrid_e334ec1d.zip

Aditi Patre
Replied On March 1, 2018 09:06 AM

Can we retain the filter settings on page size settings change ? (Dropdown displays the page-size).

Isuriya Rajan [Syncfusion]
Replied On March 5, 2018 11:26 AM

Hi Aditi, 
 
Thanks for contacting Syncfusion support, 
 
Please refer the below KB for your requirement. 
 
 
Please get back to us if you need any other assistance. 
 
Regards, 
Isuriya R 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;