Unplanned
Last Updated: 08 Apr 2020 16:14 by ADMIN
User1564
Created on: 18 Jul 2019 11:24
Category: Grid
Type: Bug Report
1
RadDatePicker in RadGrid HeaderContextMenu incorrect Date Format after Filtering

If the Page culture is set to anything other than "en-US", RadDatePicker in the HeaderContextMenu will loose the correct format and swaps the Day with the Month after filtering.

1 comment
ADMIN
Attila Antal
Posted on: 18 Jul 2019 12:22

Thank you for taking the time to report this issue!

This issue can be worked around by accessing the DatePickers and re-set their values to reflect the ones from the column.

Wire up the ClientSettings - OnHeaderMenuShowing and HeaderContextMenu - OnClientShown event handlers to the RadGrid:

<telerik:RadGrid ID="RadGrid1" runat="server">
    <ClientSettings>
        <ClientEvents OnHeaderMenuShowing="menuShowing" />
    </ClientSettings>
    <HeaderContextMenu OnClientShown="menuShown">
    </HeaderContextMenu>          
</telerik:RadGrid>


OnHeaderMenuShowing and OnClientShown event handlers:

<script type="text/javascript">
    var gridCol;
    function menuShowing(sender, args) {
        gridCol = args.get_gridColumn();
    }
    function menuShown(sender, args) {
        if (gridCol._data.ColumnType == "GridDateTimeColumn") {
            var container = $("#" + sender.get_id() + "_detached");
            var firstPicker = $telerik.findControl(container[0], "HCFMRDPFirstCond");
 
            var regex = /[^\w]/gi;
 
            if (gridCol._data.CurrentFilterValue == "") {
                firstPicker.clear();
            }
            else {
                var splitBy = regex.exec(gridCol._data.CurrentFilterValue); // returns either dot " . " or " / " or " - "
                var firstDateDetails = gridCol._data.CurrentFilterValue.split(splitBy);
                var firstDate = new Date(firstDateDetails[2], firstDateDetails[1] - 1, firstDateDetails[0]);
 
                firstPicker.set_selectedDate(firstDate);
            }
 
            var secondPicker = $telerik.findControl(container[0], "HCFMRDPSecondCond");
 
            if (gridCol._data.AndCurrentFilterValue == "") {
                secondPicker.clear();
            }
            else {
                var splitBy = regex.exec(gridCol._data.AndCurrentFilterValue); // returns either dot " . " or " / " or " - "
                var secondDateDetails = gridCol._data.AndCurrentFilterValue.split(splitBy);
                var secondDate = new Date(secondDateDetails[2], secondDateDetails[1] - 1, secondDateDetails[0]);
                secondPicker.set_selectedDate(secondDate);
            }
        }
    }
</script>

Please accept our apology for any inconvenience this may have caused.