Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have Radgrid in which I've a cloumn name 'ModifiedOn' on which I'm using two Raddatepickers:- FromDate and ToDate. I need to filter this RadGrid on the basis of date, month and year selected from this column header. Whenever I select a date either from FromDate or ToDate, the RadGrid tableView.filter("columnModifiedOn", fromDate + " " + toDate, "Between"); doesn't filter the grid on the basis of selected dates, instead it treat these selected dates as strings and filter the grid til basic of date and month this was not consider the year (dd/MM not with dd/MM/yyyy).

Please let me know if anyone knows the answer.

What I have tried:

JavaScript
function FromDateSelected(sender, args) {
    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
    var ToPicker = $find('<%# ((GridItem)Container).FindControl("ToOrderDatePicker").ClientID %>');

    var fromDate = FormatSelectedDate(sender);
    var toDate = FormatToSelectedDate(ToPicker);

    tableView.filter("columnModifiedOn", fromDate + " " + toDate, "Between");
}

function ToDateSelected(sender, args) {
    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
    var FromPicker = $find('<%# ((GridItem)Container).FindControl("FromOrderDatePicker").ClientID %>');

    var fromDate = FormatSelectedDate(FromPicker);
    var toDate = FormatToSelectedDate(sender);

    tableView.filter("columnModifiedOn", fromDate + " " + toDate, "Between");
}

function FormatSelectedDate(picker) {
    var date = picker.get_selectedDate();
    var dateInput = picker.get_dateInput();
    var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());

    return formattedDate;
}

function FormatToSelectedDate(picker) {
    var date = picker.get_selectedDate();
    date.setDate(date.getDate() + 1);
    var dateInput = picker.get_dateInput();
    var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());

    return formattedDate;
}
Posted
Updated 11-Jun-17 21:14pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900