PDA

View Full Version : Am unable to do date filter



rubynile
5 Aug 2009, 1:32 AM
Am doing date filter for list.Its working well if all list have date.If a list is without date its giving error.how to solve this.I want to filter the list if any 1 of the list item didnt have date also.If anyone know help me.This is the validation code am using


validateRecord: function(record) {
var val = record.get(this.dataIndex).clearTime(true).getTime();

if(this.dates.on.checked && val != this.getFieldValue('on').clearTime(true).getTime()) {
return false;
}
if(this.dates.before.checked && val >= this.getFieldValue('before').clearTime(true).getTime()) {
return false;
}
if(this.dates.after.checked && val <= this.getFieldValue('after').clearTime(true).getTime()) {
return false;
}
return true;
}

Condor
5 Aug 2009, 1:34 AM
Should empty dates be included or excluded?

rubynile
5 Aug 2009, 1:46 AM
My list having some of the date field as empty and some with value.But i have to filter this list.How to do this.

rubynile
5 Aug 2009, 1:50 AM
I have to filter the list with empty date field also

Condor
5 Aug 2009, 2:54 AM
validateRecord: function(record) {
var val = record.get(this.dataIndex);
val = Ext.isDate(val) ? val.clearTime(true).getTime() : null;

if(this.dates.on.checked && (!val || val != this.getFieldValue('on').clearTime(true).getTime())) {
return false; // empty dates are not matched by exact date
}
if(this.dates.before.checked && val && val >= this.getFieldValue('before').clearTime(true).getTime()) {
return false; // empty dates are before set date
}
if(this.dates.after.checked && (!val || val <= this.getFieldValue('after').clearTime(true).getTime())) {
return false; // empty dates are not after set date
}
return true;
}

rubynile
5 Aug 2009, 4:46 AM
Thank you Condor.I got output