Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
IgCombo filter on multiple properties
posted

Hi,

I am using the IgGrid where at least one column is an object. When the user is editing that row I am using the IgCombo to change the object. The data source is set when iggrid updating event is triggered since I dont have the data for the combobox when the page loads. When the user has chosen an object from the list it displays the object.Name property in the grid. And that works, but my problem is:

 The IgCombo should display multiple properties in the list, but not nearly all. And those properties that are visible, should the user be able to filter by. I have made four properties visible by using: itemTemplate: "${Name} | ${Id} | ${object1.Property1} | ${object2.property1}"

But as long as textKey is set to Name, it only filters by name. I want the filtering to behave as the user writes, it should check all four properties and if any is matching/containing the letter/word, then display those rows in the combolist.

I tried to make a hack by creating my own filtering ny binding to the IgCombo filtering event like this:

But it behaves strange when I set the datasource while filtering/having the combox open, so it was not an usable solution.

$(document).delegate($("#mainGrid").igGridUpdating("editorForKey", "Product"), "igcombofiltering", function (evt, ui) {

var combo = $("#mainGrid").igGridUpdating("editorForKey", "Product");
var text = combo.igCombo("text");
var list = [];
if (!(text === undefined || text === null)) {
$.each(scope.ProductList, function (value, key) {
if (this.Name.toLowerCase().indexOf(text) > -1) {
list.push(this);
return true;
}//Do similar checks for all properties that should be filtered
});
}
combo.igCombo("option", "dataSource", list);
combo.igCombo("dataBind");
});