Dear All,
I am new to Telerik RAD Controls and new to this forum too...
Actually,
I am using a Telerik Rad Grid. With in the detail grid, I got various columns, say col1 and col2, col3. When the user entered a value in col1 and col2, I should add them and set to the col3.
In the itemdatabound event I have added code to add javascript method to get fired onfocuschange of col1 and col2
var
col1 = item["col1"].Controls[0] as RadNumericTextBox;
var col2 = item["col2"].Controls[0] as RadNumericTextBox;
var col3 = item["col3"].Controls[0] as RadNumericTextBox;
string clientIds =
"'" + col1.ClientID + "' ," +
"'" + col2.ClientID + "' ," +
"'" + col3.ClientID + "'";
col1.Attributes.Add(
"onfocusout", "javascript:calculate(" + clientIds + ");");
col2.Attributes.Add(
"onfocusout", "javascript:calculate(" + clientIds + ");");
The following is the javascript method:
<
script type="text/javascript" language="javascript">
function calculate(price, quantity, totalAmount) {
var text1 = document.getElementById(price);
var text2 = document.getElementById(quantity);
var text3 = document.getElementById(totalAmount);
var total = text1.value * 1 + text2.value * 1;
alert(total);
alert(document.getElementById(totalAmount));
document.getElementById(totalAmount).value = total;
return true;
}
</script>
The javascript method is getting fired,and I am able to read the value entered by the user in the col1 and col2. How ever, when I set it to col3, it is not getting updated.
It is urgent, any ideas, please?
Regards,
Venkat
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
TableCell tc = new TableCell();
footerItem.Cells[5].Text = "<
b
>Overall Rating:</
b
>";
footerItem.Cells[5].HorizontalAlign = HorizontalAlign.Right;
//Add group rating summary
RadRating radrateemp = new RadRating();
RadRating radratesuper = new RadRating();
radrateemp.ReadOnly = true;
radrateemp.ID = "EmpRatingOverall";
radratesuper.ReadOnly = true;
radratesuper.ID = "SuperRatingOverall";
footerItem.Cells[7].Controls.Add(radrateemp);
footerItem.Cells[6].Controls.Add(radratesuper);
}
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
>
<
MasterTableView
DataSourceID
=
"SqlDataSource1"
AllowSorting
=
"true"
DataKeyNames
=
"id"
AllowPaging
=
"true"
PageSize
=
"10"
AllowNaturalSort
=
"false"
AutoGenerateColumns
=
"false"
>
<
Columns
>
<
telerik:GridTemplateColumn
HeaderText
=
"Action"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"lbview"
CausesValidation
=
"false"
CommandName
=
"ViewThread"
CommandArgument='<%#Eval("id") %>' runat="server">View</
asp:LinkButton
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Author"
HeaderText
=
"Author"
HeaderButtonType
=
"TextButton"
DataField
=
"author_name"
UniqueName
=
"Author"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Title"
HeaderText
=
"Title"
HeaderButtonType
=
"TextButton"
DataField
=
"title"
UniqueName
=
"Title"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"PostDate"
DataField
=
"date_created"
HeaderText
=
"Post Date"
HeaderButtonType
=
"TextButton"
UniqueName
=
"PostDate"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"LastCommented"
HeaderText
=
"Last Commented"
HeaderButtonType
=
"TextButton"
DataField
=
"last_commented"
UniqueName
=
"LastCommented"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Rating"
HeaderText
=
"Rating"
HeaderButtonType
=
"TextButton"
DataField
=
"rating"
DataFormatString
=
"{0:N1}"
UniqueName
=
"Rating"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
I have attached the screenshot of the RadGrid displaying that weird textbox.