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