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

8 posts, 0 answers
  1. Tim
    Tim avatar
    7 posts
    Member since:
    Jan 2016

    Posted 27 Jun Link to this post

    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.

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 30 Jun Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tim
    Tim avatar
    7 posts
    Member since:
    Jan 2016

    Posted 11 Jul Link to this post

    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.   

  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 13 Jul Link to this post

    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.
  6. Tim
    Tim avatar
    7 posts
    Member since:
    Jan 2016

    Posted 13 Jul in reply to Viktor Tachev Link to this post

    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");
    }

  7. Tim
    Tim avatar
    7 posts
    Member since:
    Jan 2016

    Posted 13 Jul Link to this post

    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"

  8. Tim
    Tim avatar
    7 posts
    Member since:
    Jan 2016

    Posted 13 Jul Link to this post

    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?

  9. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 15 Jul Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017