DatePicker values are getting copied from one row to other when selected to edit

2 posts, 1 answers
  1. Suresh
    Suresh avatar
    9 posts
    Member since:
    May 2015

    Posted 19 Nov 2015 Link to this post

    Hi Team,

    DatePicker values are getting copied from one row to other when selected to edit in RadGrid BatchEdit model.

    First, I clicked in DatePicker column in first row and clicked in DatePicker column in second row. The value of DatePicker in first row is getting copied to DatePicker in second row.

    I am having following code in BatchEditOpened event, here I am just trying to set minimum date for StartDate datepicker.

    function BatchEditOpened(sender, args) {

    switch (args.get_columnUniqueName()) {

       case "StartDate":
          var dtStartDate = $find($telerik.$("[id$='dtStartDate']").attr("id"));                       
            if (dtStartDate.get_selectedDate()) {
               var minDate = new Date(dtStartDate.get_selectedDate());
               minDate.setDate(minDate.getDate());
               dtStartDate.set_minDate(minDate);
             }

           break;

    }

    Please let me know why it is copying value instead of just setting minimum date. If I remove code in BatchEditOpened, it is not copying values.

  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 23 Nov 2015 Link to this post

    Hi Suresh,

    The issue that you are facing is due to the fact that there will be only one editor generated for the entire column and that editor will be moved along the edited cells, which means that the editor will preserve the previous configurations (the previous minDate value), which in other hand will prevent the setting of the value from the cell to the editor in some scenarios.

    A working approach for the requirement that you have is achievable within the OnBatchEditOpening event with the following modification of your logic:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function BatchEditOpening(sender, args) {
                switch (args.get_columnUniqueName()) {
                    case "StartDate":
                        var dtStartDate = $find($telerik.$("[id$='dtStartDate']").attr("id"));
                        var cellValue = sender.get_batchEditingManager().getCellValue(args.get_cell());
                        if (cellValue) {
                            var minDate = new Date(cellValue);
                            minDate.setHours(0);
                            minDate.setMinutes(0);
                            minDate.setSeconds(0);
                            dtStartDate.set_minDate(minDate);
                        }
                        break;
                }
            }
        </script>
    </telerik:RadCodeBlock>

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top