Gdy masz tylko jedną opcję lub nie jesteś zadowolony z układu, możesz całkowicie dostosować sterowanie filtrem, używając przeciążenia "ui: func (element) {}", które występuje w późniejszych wersjach Kendo (np. v2013.1.319)
columns : [
{ field: "MyCity", width: 80, title : "City", filterable: customTextFilter },
{ field: "CreatedAt", width: 72, title: "Created", filterable: $scope.customDateFilter }
]
Oto funkcja, która następnie dostosowuje wygląd:
var customTextFilter =
{
extra : false,
operators : { string : { contains : "Contains"}},
ui : function(element)
{
var parent = element.parent();
while(parent.children().length > 1)
$(parent.children()[0]).remove();
parent.prepend("<input data-bind=\"value:filters[0].value\" class=\"k-textbox\" type=\"text\">");
}
}
Oto przykład mający dwa date pudełka z GTE formacie/LTE:
var customDateFilter =
{
extra : true,
operators : { },
ui : function(element)
{
var parent = element.parent();
while(parent.children().length > 1)
$(parent.children()[0]).remove();
parent.prepend(
"On or after:<br/><span class=\"k-widget k-datepicker k-header\">" +
"<span class=\"k-picker-wrap k-state-default\">" +
"<input data-bind=\"value:filters[0].value\" class=\"k-input\" type=\"text\" data-role=\"datepicker\"" +
" style=\"width: 100%\" role=\"textbox\" aria-haspopup=\"true\" aria-expanded=\"false\" aria-disabled=\"false\" " +
" aria-readonly=\"false\" aria-label=\"Choose a date\">" +
"<span unselectable=\"on\" class=\"k-select\" role=\"button\">" +
"<span unselectable=\"on\" class=\"k-icon k-i-calendar\">select</span></span></span></span>" +
"<br/>On or before:<br/>" +
"<span class=\"k-widget k-datepicker k-header\"><span class=\"k-picker-wrap k-state-default\">" +
"<input data-bind=\"value: filters[1].value\" class=\"k-input\" type=\"text\" data-role=\"datepicker\"" +
" style=\"width: 100%\" role=\"textbox\" aria-haspopup=\"true\" aria-expanded=\"false\" " +
" aria-disabled=\"false\" aria-readonly=\"false\" aria-label=\"Choose a date\">" +
"<span unselectable=\"on\" class=\"k-select\" role=\"button\">" +
"<span unselectable=\"on\" class=\"k-icon k-i-calendar\">select</span></span></span></span>"
);
}
};
Oczywiście możesz dowolnie szablonować i tworzyć różne niestandardowe filtry dla Date, Boolean, itd. - zauważ, że dla wersji Date powyżej, jeśli chcesz ustawić operatorów poprawnie, aby powiedzieć "gte" i "lte" dla filtr [0] Dopełniającym operatorem i filtrować [1] Dopełniającym operatorem można po prostu ustawić, że na dataSource.filter atrybut tak:
dataSource: {
transport :
{
read : function(context)
{
//note that here context.filter.filters has the array
//of applied filters -- you can write a custom RESTful call
//such as angular $http.get() or use Kendo native format to
//send filter options to server.
}
},
//filter settings here initialize filter[0], filter[1], etc.
filter : [
{ field : "CreatedAt", operator : "gte" },
{ field : "CreatedAt", operator : "lte" }]
}
próby aktualizacji do najnowszej kompilacji wewnętrznego, jak to zostało ustalone o ile pamiętam. –
@Pechka Który działa - Jeśli umieścisz to jako odpowiedź, oznaczy to jako zaakceptowaną odpowiedź. Dla odniesienia v2012.3.1114 (które było listopadowym wydaniem) nie działa. Błąd został naprawiony przez v2012.3.1304 i zgodnie z innym wyszukiwaniem, które zostanie w pełni opublikowane w lutym 2013 roku. –
Dzięki za dodatkowe informacje zamieściłem odpowiedź, która pomogłaby również innym użytkownikom. –