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

[Solved] Filter on non displayed column lost when filtering again

3 Answers 133 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.
Julien
Top achievements
Rank 1
Julien asked on 04 Jul 2012, 02:03 PM
Hi,

I've a Asp.Net MVC telerik's Grid which display one of my biggest table. Not  all informations are displayed. But I've some links which redirect to the action containing the grid.

Those links basically build and url with telerik parameter(e.g. ...TheGrid-filter=SecondVar~eq~'sdfg'and~Status~eq~1). It works like a charm, telerik read those parameter, and apply filters/Sort on my model. 

let's take a fictive case:

I've the following model

public class MyModel{
 public String A{get;set;}
 public String C{get;set;}
 public String D{get;set;}
 public String E{get;set;}
}

I've a Grid named "TheGrid" with three columns, bounds to A, B and C(not D, because we don't want it to be displayed or because it takes to much spaces).

I load the view with this: 

mydomain/MyController/MyAction?TheGrid-filter=E~eq~'YEPA'

I got my grid correctly filtered, but now if I set a filter on the C column, my current filter on the E column will be ignored.

At this moment telerik should know that this parameter filters its data, because it's a part of its TheGrid-filter attribute, even if it doesn't find any column bound on this data, but it seems it's isn't the case.

So how can I do that?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Jul 2012, 09:05 AM
Hello Julien,

The Grid gets the current filters from the columns collection so if the property is not bound, the filter will be lost after any operation. In order to persist it and not show the column, you could bind property and hide the column with the Hidden configuration method. An alternative is to add the filter parameters to the route values and filter the data before passing it to the Grid.

Regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Dennis
Top achievements
Rank 1
answered on 09 Jul 2012, 05:28 PM
Can you please explain how to bind the parameter if it is not in the results being returned? I have a dropdownlist box that when I click search I pass the parameter to method GetValue(ddlValue). and in the grid there is a .DataBinding(dataBinding => dataBinding.Ajax().Select("_Filtering", "Home") but I don't see how to pass the value to the _Filtering method. In the example it is just a method that returns all data. I don't want to do that, i want/need the data to be paged/sorted on the dataset that was returned from the click of the search button.

Thanks
Dennis
0
Daniel
Telerik team
answered on 12 Jul 2012, 10:14 AM
Hello Dennis,

Basically you should add the ddlValue parameter as a route value to the Select action:

.DataBinding(dataBinding => dataBinding.Ajax().Select("_Filtering", "Home", new { ddlValue = ViewBag.ddlValue }))
and filter the collection based on the value before returning it as result:
[GridAction]
public ActionResult _Filtering(string ddlValue)
{
    var data = GetData().Where(d => d.MyProperty == ddlValue);
    return View(new GridModel(data));
}


Kind regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Julien
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Dennis
Top achievements
Rank 1
Share this question
or