How do you get/set values from RowEditTemplate during onTemplateClosed client event using javascript? can someone share code with me? Thanks!
Hi davefevold,
By the time that the TemplateClosed event fires, the values will already have been carried to the row's cells. So you could check those cells. The row is available off of the event args. If you wanted to do validation to prevent the template closing, use the TemplateClosing event, then you'd have to find the objects using $get(id), $find(id), or document.getElementById(id) calls. Similar to what we do internally.
regards,
David Young
Hello davefevold,
Let us know if you need further assistance after the provided by David suggestion.
Kind Regards,
Tsvetelina Georgieva
Infragistics, Inc.
I've tried the following code to retieve values from a textbox on the RowEdit Template but it doesn't work...what am I doing wrong?
function onTemplateClosing(sender, e) { var grid = sender; var ret = grid.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate(); var oInstrumentNbr = ret.$get({"Instrument_No"}).value;}
Hi Dave,
That code is wrong. You would use $get on its own.
var oInstrumentNbr = $get("Instrument_No").value; But, the id has to be the whole client id, since asp.net will give it a name containing parent ids. Or if you are using CLR 4, you could try setting id to static. Another option is to search through the child nodes of the ret template div. This can be found off of the ret behavior as ret._templateDiv. Then start searching childNodes collection to find your editors. But these will be straight html elements. If you have any of our controls, you'd be better off trying to find them with $find(id). You just need the client id. Hope this helps you out.
-Dave
Can you give me a full javascript coding example for getting the value of a WebDatePicker from a RowEditTemplate during the TemplateClosing client event?
Hi,
Here is is.
function templateClosing(sender, args)
{
var ret = sender.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate();
var colKey = "BirthDate";
var binding = ret._bindings._getObjectByAdr(colKey);
var datePicker = $find(binding.get_clientID());
var dateVal = datePicker.get_value();
}
Great...thanks!!!
If I wanted to check and then set the date value would I then do the following?
function templateClosing(sender, args) { var ret = sender.get_behaviors().get_editingCore().get_behaviors().get_rowEditingTemplate(); var colKey = "BirthDate"; var binding = ret._bindings._getObjectByAdr(colKey); var datePicker = $find(binding.get_clientID()); var dateVal = datePicker.get_value(); if (dateVal == null) { datePicker.set_value('12/31/9999') } }
if (dateVal == null) {
datePicker.set_value('12/31/9999')
I would think that would work, so long as the date picker will return you null for the date if it is not set.
After using the the same code, the date was null and I still received the following error:
{"String was not recognized as a valid DateTime."}
Any other ideas on how to replace the null date?
Thanks!
When I try to replace the date's null value with the below code, it does not change the date's value when reaching the wdgSecIns_RowUpdating Sub.
var
colKey3 = "Canceled_Date";
datePicker3.set_value(
"12/31/9999");
I'm not intimately familar with the WebDatePicker, however when I look at the source code, it appears that it expects a Date object for set_value(), whereas you are passing a string. That could be the source of your problem. Try that and let me know.
thanks,Dave
Dave, it doesn't matter what I put in the set_value() for the date object...I still get the error message. If I have all date fields filled in for the RowEditTemplate, once I press the ok button, the ret closes fine and proceeds to the WebDataGrid_RowUpdating sub. If there is a date field not filled in or null, when I press the ok button, I get the error message and it never proceeds to the WebDataGrid_RowUpdating sub. That is why I'm trying to catch it and change the date before it blows up. Thanks for any help you can provide!
Dave, I found my issue...I had the my client event defined wrong, as follows. I was trying to change the values after the template had closed already...thx for your help.
TemplateClosed
="onTemplateClosing"