on 07-05-2021 7:20 AM
I have created a filter page. In that I have added a date picker. I want to filter using the date picker in mdk. is there any way to do that ?
Thank You
In MDK 5.2 release, we introduced supporting Rules for Result Object in Filter page, you can customize the filter values return out of Date Picker selection. You have to use the createFilterCriteria
to create FilterCriteria
object and finally return an array.
For example, i am calling this Rule to the Result of a page where i have DatePicker FormCell control.
This returns list of SalesOrders created on a selected date.
export default function FilterResults_SO(context) {
let datePickerValue = context.evaluateTargetPath('#Page:FormCell_SO/#Control:DatePicker/#Value');
var d = new Date(datePickerValue);
var result = d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2);
var result1 = `${result}T00:00:00`;
var result2 = `${result}T23:59:59`;
var filterQuery = `CreatedAt ge datetime'${result1}' and CreatedAt le datetime'${result2}'`;
result1 = [filterQuery];
let filterCriteria = context.createFilterCriteria(context.filterTypeEnum.Filter, undefined, undefined, result1, true);
let filterResults = [filterCriteria];
return filterResults;
Of course, you need to adjust the rule according to your scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jitendra Kansal,
Your code for date filter is working absolutely fine. But I am facing another issue with it. In the filter page I also have a filter property. I was returning that as well in the result section.
But the moment I add the rule for the date filter, the above command gets removed. is there a way to do it in a single rule.
Thank You
kohlisamvaran76
You need to return the value of all filters in your new rule. Example:
let filterResults = [];
let result = context.evaluateTargetPath('#Page:IncomeHist_Filter/#Control:SortBy/#Value');
filterResults.push(result);
result = context.evaluateTargetPath('#Page:IncomeHist_Filter/#Control:ListPickerFormCellBank/#FilterValue');
filterResults.push(result);
result = context.evaluateTargetPath('#Page:IncomeHist_Filter/#Control:ListPickerFormCellProof/#FilterValue');
filterResults.push(result);
result = context.evaluateTargetPath('#Page:IncomeHist_Filter/#Control:ListPickerFormCellColType/#FilterValue');
filterResults.push(result);
result = context.evaluateTargetPath('#Page:IncomeHist_Filter/#Control:ListPickerFormCellRep/#FilterValue');
filterResults.push(result);
if (filter) {
result = `Budat ge datetime'${fromIncDate}' and Budat le datetime'${toIncDate}'`;
let simplePropertyFilterResult = context.createFilterCriteria(context.filterTypeEnum.Filter, 'Budat', 'Budat', [result], true);
filterResults.push(simplePropertyFilterResult);
}
return filterResults;
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.