This is a migrated thread and some comments may be shown as answers.

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

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suresh
Top achievements
Rank 1
Suresh asked on 19 Nov 2015, 06:29 AM

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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 23 Nov 2015, 01:08 PM
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
Tags
Grid
Asked by
Suresh
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or