Kendo DataSource Custom Filter Operator

Contoh: mau mem-filter data pada grid yang tanggal = hari ini

[script lang=”javascript”]

function displayCurrentMonth()
{
//dsGridOngoing.filter({ field: ‘SubmittedDate’, operator: ‘eq’, value: Date(2017,8,21) });
var date = new Date(2017, 8, 21);

dsGridOngoing.filter({
field: ‘SubmittedDate’,
//operator: ‘eq’,
operator: function(fieldDate) {

var parsedSelectedDate = kendo.parseDate(date);
//parse the field date in order to ignore the time
var parsedFieldDate = new Date(fieldDate.getFullYear(),  fieldDate.getMonth(), fieldDate.getDate());
var result = (parsedFieldDate.getDate() == parsedSelectedDate.getDate());

return result;

},
value: date
});
}

[/script]

Chandra Oemaryadi has written 244 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>