$telerik.cancelRawEvent(e);I do not have any event handled at all in the code behind file.
Following is the code for the aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="HarborSales.Portal.Modules.Tree.Default" %> <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Tree drop node context menu</title> <telerik:RadScriptBlock runat="server" ID="radScriptBlock"> <script type="text/javascript"> function showContextMenu(e) { // alert("Dropping"); var contextMenu = $find("<%= RadContextMenu1.ClientID %>"); if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) { contextMenu.show(e); } return $telerik.cancelRawEvent(e); } function ClientNodeDropping(sender, eventArgs) { showContextMenu(eventArgs.get_domEvent()); } function ClientNodeDropped(sender, eventArgs) { // alert("Dropped"); } </script> </telerik:RadScriptBlock> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="True" EnableDragAndDropBetweenNodes="True" Skin="Vista" OnClientNodeDropping="ClientNodeDropping" OnClientNodeDropped="ClientNodeDropped"> <Nodes> <telerik:RadTreeNode runat="server" Checkable="False" Text="Condos"> </telerik:RadTreeNode> <telerik:RadTreeNode runat="server" Checkable="False" Text="TownHomes"> </telerik:RadTreeNode> <telerik:RadTreeNode runat="server" Checkable="False" Text="Houses"> <Nodes> <telerik:RadTreeNode runat="server" Checkable="False" Text="House 1"> </telerik:RadTreeNode> <telerik:RadTreeNode runat="server" Checkable="False" Text="House 2"> </telerik:RadTreeNode> </Nodes> </telerik:RadTreeNode> </Nodes> <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation> <ExpandAnimation Duration="100"></ExpandAnimation> </telerik:RadTreeView> <!-- Context menu --> <telerik:RadContextMenu ID="RadContextMenu1" runat="server" Flow="Vertical" Skin="Vista"> <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> <Items> <telerik:RadMenuItem runat="server" Text="Move with children"> </telerik:RadMenuItem> <telerik:RadMenuItem runat="server" Text="Copy dragged node"> </telerik:RadMenuItem> <telerik:RadMenuItem runat="server" Text="Copy with children"> </telerik:RadMenuItem> </Items> </telerik:RadContextMenu> </div> </form> </body> </html>
Grid's binding not working after upgrade. Using commanditem btn with 'UpdateEdited' worked before upgrade. Now grid just collaspes and stays in editmode. Also no rebind after insert or delete. Thanks in advance.
public
void OnUpdateCommand(object source, GridCommandEventArgs e){
GridEditableItem gvRow = e.Item as GridEditableItem;
int
itemID0 = int.Parse(gvRow.GetDataKeyValue("Id").ToString());
Suppliers
obj = new Suppliers();
Suppliers_Details objDetails = new Suppliers_Details();
objDetails.Id = int.Parse(itemID0.ToString());
Retval = obj.UpdateItem(objDetails);
//if error
if (Retval[1] == "0"){
e.Canceled = true;
return;}
//If ok here the grid should close and rebind as before upgrade to Q3 SP2
}
//end sub
Problem description:
The sample project contains a RadGrid (2 columns, 4 rows) that switches the second column in the second and fourth rows in edit mode. The problem is that the first column does not display its value anymore (the value is "lost") while the second column is in edit mode. When I try to iterate through all the rows in Save_Command handler, I cannot get the value from these columns either.
Default.aspx
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%
@ Register TagPrefix="tlk" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%
@ Register TagPrefix="ajax" Namespace="System.Web.UI" Assembly="System.Web.Extensions" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<ajax:ScriptManager ID="ScriptManager" runat="server">
</ajax:ScriptManager>
<tlk:RadGrid ID="RadGrid1" Width="100%" AllowMultiRowEdit="true"
OnNeedDataSource="RadGrid_NeedDataSource" runat="server"
OnItemCreated="RadGrid1_ItemCreated" >
<MasterTableView ShowHeadersWhenNoRecords="true" Width="100%" AutoGenerateColumns="false" EditMode="InPlace" >
<Columns>
<tlk:GridBoundColumn UniqueName="Name" HeaderText="Name" DataField="Name" />
<tlk:GridBoundColumn UniqueName="Amount" HeaderText="Amount" DataField="Amount" />
</Columns>
<EditItemStyle BackColor="transparent" />
</MasterTableView>
<ClientSettings>
<Resizing AllowColumnResize="true" AllowRowResize="true" />
<Scrolling AllowScroll="true" UseStaticHeaders="true" />
</ClientSettings>
<HeaderStyle Width="150px" />
</tlk:RadGrid>
<div style="text-align:right; margin-top:5px">
<asp:Button ID="SaveButton" Text="Save" runat="server" OnCommand="Save_Command" />
</div>
</form>
</
body>
</
html>
Default.aspx.cs
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.Web.UI;
public
partial class _Default : System.Web.UI.Page
{
protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add(
new DataColumn("Name"));
table.Columns.Add(
new DataColumn("Amount"));
table.Rows.Add(
new object[] { "John", "11" });
table.Rows.Add(
new object[] { "David", "22" });
table.Rows.Add(
new object[] { "Elvis", "33" });
table.Rows.Add(
new object[] { "Oliver", "44" });
((
RadGrid)source).DataSource = table;
}
protected void Page_PreRender(object sender, EventArgs e)
{
RadGrid1.Items[1].Edit =
true;
RadGrid1.Items[3].Edit =
true;
RadGrid1.Rebind();
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem && e.Item.IsInEditMode)
{
foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
{
if (column is GridBoundColumn)
{
if (string.Compare(column.UniqueName, "Amount", StringComparison.InvariantCultureIgnoreCase) == 0)
{
((
GridBoundColumn)column).ReadOnly = false;
TextBox textBox = null;
if (e.Item is GridDataItem)
{
textBox = ((
TextBox)((GridDataItem)e.Item)[column.UniqueName].Controls[0]);
textBox.Style[
"width"] = "100%";
textBox.Style[
"height"] = "100%";
textBox.Style[
"border"] = "1px";
textBox.Style[
"text-align"] = "right";
}
}
else
{
((
GridBoundColumn)column).ReadOnly = true;
}
}
}
}
}
protected void Save_Command(object source, EventArgs e)
{
string name = "";
foreach (GridDataItem item in RadGrid1.Items)
{
name = item[
"Name"].Text;
}
}
}
I also have a second question: I would like to have an extra row to show the rollup on the editable column. Is it possible to have this total being updated as the user modifies the editable fields ?