Hi,
I am trying to implement a row total function in Javascript for a RadGrid. Searching the help and forums I have managed to set up a function that is called by onBlur for each of my numeric columns, but cannot seem to get the value of the fields held in the template columns.
The definition of the columns (14 in total) is:
And the javascript functin is:
Everything is getting called OK but the lines:
Always returns null for textTime. The examples on the forum here seem to indicate the syntax is correct.
Am I implementing this wrong, or is there a better way of obtaining the values?
David Penny
I am trying to implement a row total function in Javascript for a RadGrid. Searching the help and forums I have managed to set up a function that is called by onBlur for each of my numeric columns, but cannot seem to get the value of the fields held in the template columns.
The definition of the columns (14 in total) is:
<
telerik:GridTemplateColumn
UniqueName
=
"colTime1"
AllowFiltering
=
"False"
HeaderText
=
"1"
FooterStyle-Width
=
"50"
HeaderStyle-Width
=
"50"
ItemStyle-Width
=
"50"
>
<
ItemTemplate
>
<
asp:TextBox
ID
=
"editTime1"
runat
=
"server"
Width
=
"40px"
></
asp:TextBox
>
</
ItemTemplate
>
<
FooterStyle
Width
=
"50px"
/>
<
HeaderStyle
Width
=
"50px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridTemplateColumn
>
And the javascript functin is:
function valueChanged(totalTime, textbox, c, r) {
var grid = $find("<%=RadGrid1.ClientID %>");
var MasterTable = grid.get_masterTableView();
var Rows = MasterTable.get_dataItems();
var valnow = textbox.value;
var total = valnow;
for (col = 1; col < 15; col++) {
if (col != c) {
var row = Rows[r - 1];
var columnName = "EditTime".concat(col);
var textTime = row.findControl(columnName);
var colVal = textTime.get_value();
if (!isNan(colVal)) {
total += colVal;
}
else {
textTime.set_value("");
}
}
}
totalTime.set_value(total);
}
Everything is getting called OK but the lines:
var row = Rows[r - 1];
var columnName = "EditTime".concat(col);
var textTime = row.findControl(columnName);
var colVal = textTime.get_value();
Always returns null for textTime. The examples on the forum here seem to indicate the syntax is correct.
Am I implementing this wrong, or is there a better way of obtaining the values?
David Penny