Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ag-grid column search not working with object as cell value

I am using cell_renderer to define my cell, something like this:

        var cell_renderer = function(params) {
            var element = "";
            var values = params.value;
                angular.forEach(values, function(each_param){
                    element += '<a href="#/workunit/' + each_param.id + '" target="_blank">' + each_param.id +
                            '<span class="text-danger text-bold">'+
                            '<span class="" title="' + inactive_message +
                            '">' + inactive_flag + ' </span>' +
                            '<span class="" title="' + misconfigured_message +
                            '"> ' +misconfigured_flag + '</span>'+
                            '</span></a><br>';
                })
            return element;
        };

My column definnition is this:

                var testObject = {};
                testObject.headerName = "my header";
                testObject.field = each_branch;
                testObject.width = 200;
                testObject.cellClassRules = cell_class_rules;
                testObject.cellRenderer = cell_renderer;
                columnDefs.push(testObject);

Here testObject.field = each_branch , is a json object.

Hence the inbuild search functionality not working in ag-grid. Can anyone please help me here.

like image 743
undefined Avatar asked May 10 '17 12:05

undefined


1 Answers

The solution is to provide valueGetter in filter params.

Say for example you have { name: 'Some Name', id: 1 }. In that case you want to filter by the name. So:

{
  filter: 'agTextColumnFilter',
  filterParams: {
    valueGetter: params => {
      return params.data.name
    }
  }
}
like image 192
Roland Avatar answered Sep 20 '22 23:09

Roland