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

Filtering on custom columns

7 Answers 118 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.
Cookie Monster
Top achievements
Rank 1
Cookie Monster asked on 10 Feb 2010, 01:57 AM
Hello,

I have some issues with filtering on 'custom' columns.
 <%= Html.Telerik().Grid(Model) 
.Name("CustomerGrid") 
                        .Columns(columns => 
                        { 
                            columns.Add(c => c.Id).Visible(false); 
                            columns.Add(c => c.Name).Title("Group Name").Width(200); 
                            columns.Add(c => (c.Comments ==null)?string.Empty : "View" ).Title("Comments").Width(70); 
                            foreach (Products p in products) 
                            { 
                                columns.Add(c => (c.Products!=null && c. Products.Contains(t)) ?
 "V" : "X").Title(t.Value).Width(25); 
                            } 
                        }) 
                        .Ajax(ajax => ajax.Enabled(true).Action("GetCustomers", "Customer")) 
                        .Pageable() 
                        .Sortable() 
                        .Filterable() 
                        .Scrollable() 

In this example I wat to show 'comments' if customer has comments and 'x' or 'v' if he has certain products. The grid renders ok, but when I want to filter it does not work. Please refere to screenshots.
Does anybody have any idea why ?

The exception I'm having is:

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

Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details: System.InvalidCastException:Unable to cast object of type'Telerik.Web.Mvc.CompositeFilterDescriptor' to type'Telerik.Web.Mvc.FilterDescriptor'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidCastException: Unable to cast object of type 'Telerik.Web.Mvc.CompositeFilterDescriptor' 
to type  'Telerik.Web.Mvc.FilterDescriptor'.]   
DynamicModule.ns.Wrapped_CustomerController_2d423c8df8724f35b4b50c45780f24b9.Execute(RequestContext requestContext) +255
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8679150
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
            

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Feb 2010, 08:31 AM
Hello Cookie Monster,

Unfortunately I am not sure how to reproduce this problem. I suggest you open a support ticket and send a runnable project.

Regards,
Atanas Korchev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Cookie Monster
Top achievements
Rank 1
answered on 11 Feb 2010, 05:32 AM
Hi Atanas,

That's strange, cause modification is quite easy to implement.. Anyways, your system does not allow me to submit a ticket cause I'm not holding a trial licens for the FREE asp.net MVC framework.. strange again.. so I can email that example to you.

0
Atanas Korchev
Telerik team
answered on 11 Feb 2010, 08:14 AM
Hello Cookie Monster,

This is how our support system works - only customers with valid license (trial or commercial) can open support tickets. Users using the free version can only post in the forum. The latter however does not allow attachments of anything but images in order to avoid exposure of confidential customer data.

Anyway you can mail me project to atanas.korchev at telerik.com.

Regards,
Atanas Korchev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Cookie Monster
Top achievements
Rank 1
answered on 11 Feb 2010, 11:10 PM
Hi Atanas ,
I sent you the source,

My main issue with the support was that on the 'ASP.Net MVC' product page there is no 'trial' version of the product. only these 2: 
  • See Demos
  • Free Download
  • Which means that ASP.Net MVC does not get added to my product list and I cannot creat a support ticket for it.
    On the 'support ticket' page I can see only

    Please, select a product to submit your ticket:

    Hence I've downloaded ASP.Net MVC already...

    Cheers

    0
    Atanas Korchev
    Telerik team
    answered on 12 Feb 2010, 09:00 AM
    Hi Cookie Monster,

    Thank you for sending me the project. I now see what the problem is.

    The MVC Grid cannot filter currently on anything but member expressions (property or field) which belong to the bound object. This means that following:

    columns.Add(o => o.Statuses.Contains(status1, StatusComparer.Default) ? "v" : string.Empty)

    is not supported. The problem is that during Ajax binding the actual view is never processed so the grid does not know of those custom calculated columns.

    Additionally filtering can only filter on simple types (date, string, number and boolean) which means that binding the Status column will not work too.

    The only workaround I can suggest is using a ViewModel object with properties corresponding to those statuses which can be in turn bound as grid columns. Something like

    class OrderViewModel
    {
               public int OrderID {get;set;}
               public string Status1 {get; set;}
               public string Status2 {get; set;}
    }

    Greetings,
    Atanas Korchev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    0
    Cookie Monster
    Top achievements
    Rank 1
    answered on 15 Feb 2010, 01:22 AM
    Hi Atanas,

    That's fine. I'm going to implement my own sorting and filering anyway. The only thing that needs to be done that filtering popup fixed. Could you please look at the image and suggest me where to look into Telerik sources to fix that appearance issue ?
    Also, coudl you please lt me know if I can add my custom filtering options into that dropdown ?

    Cheers
    0
    Atanas Korchev
    Telerik team
    answered on 15 Feb 2010, 08:11 AM
    Hello Cookie Monster,

    Those dropdowns a repopulated based on the type of the column. You can check telerik.grid.filtering.js for more info.

    Regards,
    Atanas Korchev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Tags
    Grid
    Asked by
    Cookie Monster
    Top achievements
    Rank 1
    Answers by
    Atanas Korchev
    Telerik team
    Cookie Monster
    Top achievements
    Rank 1
    Share this question
    or