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

Multiple filter in grid Toolbar template

1 Answer 605 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 02 May 2013, 09:27 PM
Hi,

I have been following the example http://demos.kendoui.com/web/grid/toolbar-template.html with a variation and I'm stuck. 

I have a grid with multiple dropdownlist and textbox for filtering a kendo grid result. I'm having a problem implementing this but specifically when i try to compare the field value and the value in one of my control (eg dropdownlist value) . I'm trying to compare it to a field in a model list - see Award.AwardTypeID. this might be the cause why it's not working

i have a html input button for the javascript

$('#btnSearch').on("click", function (e) {
        refreshGrid();
        return false;
    });
 
function refreshGrid() {
        $filter = new Array();
        $filter.push({ field: "StudentID", operator: "contains", value: $('#txtStudentID').val() });
 
        if ($('#AwardType').val()) {
            $filter.push({ field: "Award.AwardTypeID", operator: "eq", value: $('#AwardType').val() });
        }
        var grid = $("#Grid").data("kendoGrid");
        grid.dataSource.filter($filter);
        grid.dataSource.read();
    }

Controller 

public ActionResult ApplicationSearch_Read([DataSourceRequest]DataSourceRequest request)
      {
 
          var applications = context.Applications.Include("ApplicationDetails").OrderByDescending(p => p.SubmittedDate).ToList();
          var data = applications.Select(x => new
          {
              ApplicationID = x.ApplicationID,
              SubmittedDate = x.SubmittedDate,
              FirstName = x.FirstName,
              LastName = x.LastName,
              StudentID = x.StudentID,
              IsApplicationSubmitted = x.IsApplicationSubmitted,
              Award = x.ApplicationDetails.Select(y => new {
                  AwardID = y.AwardDetail.AwardID,
                  AwardName = y.AwardDetail.Award.AwardName,
                  AwardTypeID = y.AwardDetail.Award.AwardTypeID
              })
          });
 
           
          return Json(data.ToDataSourceResult(request));
 
      }

Does anybody know how to properly do this?

Thanks,
Aaron

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 06 May 2013, 11:30 AM
Hello Aaron,

I'm not sure what exactly is the issue that you are facing by implementing the described logic. Here is a sample demonstrating multiple filtering + filtering on nested object: http://jsbin.com/izuloj/2/edit

If you filter on bar.id with value of 2 you will see the last two records displayed in the Grid.

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Aaron
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or