This is a migrated thread and some comments may be shown as answers.

How can I achieve multiple column filtering and sorting using mvc grid custom server binding

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raju
Top achievements
Rank 1
Raju asked on 03 Nov 2011, 07:23 AM

Hi,

      I am trying to implement multiple column filtering using mvc grid custom server binding. While implementing that I was able filter a single column but when I try to do filter with more than one column I am getting the below server error.

Unable to cast object of type 'Telerik.Web.Mvc.CompositeFilterDescriptor' to type 'Telerik.Web.Mvc.FilterDescriptor'.

    When I filter it by on one column it is working fine with FilterDescriptor but with more than one column it is expecting CompositeFilterDescriptor.

   If anyone knows the solution please help me.

Regards,
Raju

2 Answers, 1 is accepted

Sort by
0
Carling
Top achievements
Rank 2
answered on 17 Jan 2012, 11:23 PM
I'm having the same issue.  Works with a single filter, but not multiple.  Anyone?

here is my code:
public ActionResult _SelectAccountsBinding(GridCommand command, int serviceAgreementId)
{
  var listRequest = new ContractService.ListRequest();
  var filters = new List<ContractService.SearchFilter>();
  var sorters = new List<ContractService.Sorter>();
 
  foreach (var filter in command.FilterDescriptors)
  {
      var searchFilter = new ContractService.SearchFilter();
      var commandFilter = (FilterDescriptor)filter; // <-- won't cast
      searchFilter.Member = commandFilter.Member;
      searchFilter.SearchTerm = commandFilter.ConvertedValue.ToString();
      filters.Add(searchFilter);
  }
...
0
Carling
Top achievements
Rank 2
answered on 18 Jan 2012, 03:31 PM
Tags
Grid
Asked by
Raju
Top achievements
Rank 1
Answers by
Carling
Top achievements
Rank 2
Share this question
or