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

Set Date when value changes from another column while in Batch Edit mode

7 Answers 196 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 27 Jun 2016, 05:59 PM

Hello,

     My Grid is in GridEditMode.Batch.  I have two template columns.

      First Template Column uses a RadNumericTextBox
      Second Template Column uses a RadDatePicker.

 

Could you explain how to update the RadDatePicker's date when the RadNumericTextBox value changes USING the RadNumericTextBox's OnValueChanged CLIENT event please.

7 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 30 Jun 2016, 09:22 AM
Hi Tim,

Based on the description I guess that you have EditType set to Row for the grid. If that is the case you can use the following logic to set the date in the picker when the value in the numeric input changes.


function clientValueChanged(sender, args) {
    var tableRow = $telerik.$(sender.get_element()).closest("tr")[0];
    var datePicker = $telerik.findControl(tableRow, "DatePicker1");
 
    datePicker.set_selectedDate(new Date());   
}


Note that "DatePicker1" is the ID of the RadDatePicker control.


Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 11 Jul 2016, 04:18 PM

Thank you this is a good solution to get all items from the editItemTemplate when the grid is set to edit mode.  Also I did set my EdityType to row.  I think that is necessary in order to get the datePicker Control as the control seems to be only visible when in edit mode.

One more note to highlight is that using $Telerik calls the correct JS API to use with the telerik controls.  My mistake was trying to use the $ as JQuery uses for their functions.  

Thank you again Viktor for pointing me in the correct direction.  I can know manage the grid on the client very easily.   

0
Viktor Tachev
Telerik team
answered on 13 Jul 2016, 02:36 PM
Hello Tim,

I am glad that the suggested approach is working for you. I just wanted to add a quick note.

The $telerik.$ is alias for jQuery that is shipped with the controls. You should be able to use both $telerik.$ and $. Please examine the following article that describes using jQuery in more detail:



Regards,
Viktor Tachev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 13 Jul 2016, 03:19 PM

Hello Viktor,

     Thank you for the reference to the article I am currently studying it to ensure I have references set correctly within my application.  In the meantime I have run into another problem.  I moved my RadDatePicker into a detail table within a Hierarchy Grid.  In this scenario I am using the OnBatchEditOpened event.

      - First I am getting the value of a checkbox.
      - If the checkbox is checked I am disabling the RadDatePicker

   Everything is working fine when I first enter one of the detail tables. It's when I move into a DIFFERENT DETAIL TABLE the values that I am receiving are the values from the last record that was in edit mode on the previous detail table.  How can I get the updated values from the record in the other detail table. Here's my code...

function OnBatchEditOpened (sender, args){
    var tableRow = $telerik.$(sender.get_element()).closest("tr")[0];
var datePicker = $telerik.findControl(tableRow, "DatePicker1");
    var datePicker = $telerik.findControl(tableRow, "DatePicker1");
}

0
Tim
Top achievements
Rank 1
answered on 13 Jul 2016, 03:27 PM

Sorry I accidently sent the reply before I completed writing it.
Here is my code.

function OnBatchEditOpened (sender, args){
    var tableRow = $telerik.$(sender.get_element()).closest("tr")[0];
    var checkbox = $telerik.findControl(tableRow, "Checkbox1");
    var datePicker = $telerik.findControl(tableRow, "DatePicker1");

     If(checkbox1.checked){
        datePicker.set_enabled(false);

     }
 }
NOTE: I am using batch edit mode, Editype=" Row", OpenEditingEvent="MouseOver"

0
Tim
Top achievements
Rank 1
answered on 13 Jul 2016, 04:59 PM

function OnBatchEditOpened (sender, args){
           tableRow = args.get_row();
     }
 }

This method on args sends the correct row, but how could I get a telerik RadDatePicker object from it?

0
Viktor Tachev
Telerik team
answered on 15 Jul 2016, 09:16 AM
Hello Tim,

The BatchEditOpened event is raised for each of the cells in the edited row. If you would like to modify the value for the DatePicker control in that event you can use logic similar to the following:


function batchEditOpened(sender, args) {
    var tableRow = args.get_row();
 
    var datePicker = $telerik.findControl(tableRow, "DatePicker1");
 
    if (datePicker) {
        datePicker.set_selectedDate(new Date());
    }
}


With that said, note that when Batch Edit mode is enabled there is only one editor rendered for each column in the grid. This control is shown and hidden dynamically via internal logic. This is why you may see the previous values in the date picker.


Regards,
Viktor Tachev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
DatePicker
Asked by
Tim
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Tim
Top achievements
Rank 1
Share this question
or