<div id='paddingBox'> <div id='moveBox'> </div></div><style type='text/css'> #moveBox { position: fixed; background-color: Blue;/*Or whatever*/ filter: alpha(opacity=50); opacity: 0.5; -moz-opacity: 0.5; } #paddingBox { display: none; position: fixed; left: 0; top: 0; width: 100%; background-color: White; height: 100%; filter: alpha(opacity=1); opacity: 0.01; -moz-opacity: 0.01; }</style>function RadTreeList1_ItemCreated(sender, args) { var item = args.get_item(); var elem = item.get_element(); var rowDrop = function(dropped, onto) { /*Do something with the two rows here.*/ } $(elem).mousedown(function(e) { var mde = e ? e : event; if (!e.srcElement.id.endsWith("ExpandCollapseButton")) { var items = sender.get_dataItems(); var hoveredItem = null; $("#paddingBox").show(); $("#moveBox").css({ left: mde.clientX - mde.offsetX, top: mde.clientY - mde.offsetY, width: elem.clientWidth, height: elem.clientHeight }); $(document).mousemove(function(e) { var mme = e ? e : event; $("#moveBox").css({ left: mme.clientX - mde.offsetX, top: mme.clientY - mde.offsetY }); for (var i = 0; i < items.length; i++) { var delem = items[i].get_element(); if (delem != elem) { var offset = $(delem).offset(); var left = offset.left; var right = left + $(delem).width(); var top = offset.top; var bottom = top + $(delem).height(); if (mme.clientX > left && mme.clientX < right && mme.clientY > top && mme.clientY < bottom) { $(delem).css({ "background-color": "#29DC4F", /*Or whatever*/
"filter": "alpha(opacity=50)", "opacity": "0.5" }); hoveredItem = delem; } else { if (hoveredItem == delem) { hoveredItem = null; } $(delem).css({ "background-color": "", "filter": "", "opacity": "" }); } } } }); $(document).mouseup(function() { $("#paddingBox").hide(); $(document).unbind("mousemove"); if (hoveredItem) { rowDrop(elem, hoveredItem); } }); } });}<
telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function updateChanges()
{
ProductUpdate.AddProductLineItem(15705, 32608, 2, 1, 1, 1, 1, updateGrid);
}
function updateGrid(result)
{
var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
var grid = $find("<%= RadGrid1.ClientID %>");
grid.repaint();
}
</script>
</
telerik:RadCodeBlock>
<
telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="ProductUpdate.asmx" />
</Services>
</telerik:RadScriptManager>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Services;
using
System.Web.Script.Services;
using
System.Data;
using
System.Data.SqlClient;
using
System.Configuration;
///
<summary>
///
Summary description for ProductUpdate
///
</summary>
[
WebService(Namespace = "http://tempuri.org/")]
[
WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[
ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public
class ProductUpdate : System.Web.Services.WebService {
public ProductUpdate () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[
WebMethod (EnableSession=true)]
public string AddProductLineItem(int bidID, int bidAddressID, int productID, int quantity, double originalPrice, double price) {
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HarvestWSConnectionString"].ConnectionString);
conn.Open();
string sql = @"INSERT INTO BidDetail (BidId, BidAddressID, ProductID, Quantity, OriginalPrice, Price)
VALUES (@BidId, @BidAddressID, @ProductID, @Quantity, @OriginalPrice, @Price)"
;
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add(
new SqlParameter("@BidID", bidID));
cmd.Parameters.Add(
new SqlParameter("@BidAddressID", bidAddressID));
cmd.Parameters.Add(
new SqlParameter("@ProductID", productID));
cmd.Parameters.Add(
new SqlParameter("@Quantity", quantity));
cmd.Parameters.Add(
new SqlParameter("@OriginalPrice", originalPrice));
cmd.Parameters.Add(
new SqlParameter("@Price", price));
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
conn.Close();
return "Brandon was here";
}
}
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.