var Conditions = { 'Number': ['=', '!=', '>', '<'], 'String': ['Contains', '=', '!='], findByType: function(type) { for (p in this) { if (typeof this[p] === "object" && p == type) { return this[p]; } } return []; } }; function ViewModel(columnsSource) { this.nextFileterBinaryConditions = ['AND', 'OR']; this.columns = ko.observableArray(columnsSource); this.filters = ko.observableArray([new Filter()]); this.addFilter = function(filterObj) { var currentIndex = ko.utils.arrayIndexOf(this.filters(), filterObj); this.filters.splice(currentIndex + 1, 0, new Filter()); }; this.removeFilter = function(filterObj) { this.filters.remove(filterObj); if (this.filters().length == 0) { this.addFilter(); } }; this.postFilters = function() { var items = ko.toJS(this.filters()); var mappedItems = ko.utils.arrayMap(items, function(filter) { delete filter.ColumnObj; delete filter.AvailableConditions; return filter; }); alert(ko.toJSON(mappedItems)); }; }; ko.applyBindings(new ViewModel(_columns));