Hello!
I'm still using the classic RadTreeView and can't find out why the click event is not fireing. I'm using ExpandMode="ServerSideCallBack".
Here my code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %>
<!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
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:ScriptManager
ID
=
"SM"
runat
=
"server"
/>
<
radT:RadTreeView
ID
=
"tree"
runat
=
"server"
OnNodeClick
=
"tree_NodeClick"
OnNodeExpand
=
"tree_NodeExpand"
>
<
Nodes
>
<
radT:RadTreeNode
runat
=
"server"
ExpandMode
=
"ServerSideCallBack"
Text
=
"Test"
/>
</
Nodes
>
</
radT:RadTreeView
>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
Telerik.WebControls;
public
partial
class
_Default : System.Web.UI.Page {
protected
void
tree_NodeExpand(
object
sender, RadTreeNodeEventArgs e) {
var newNode =
new
RadTreeNode(
"New Node"
);
e.NodeClicked.Nodes.Add(newNode);
}
protected
void
tree_NodeClick(
object
sender, RadTreeNodeEventArgs e) {
Console.WriteLine(e.NodeClicked.Text);
}
}
Thanks for helping!
Regards,
Tonino.
Hi all
I would like to know if it is possible exclude exporting of some control inside the export area. ( button for example )
Tks in advance
Walter
Hi,
I am in the need of use the RadDiagram control to show a graph of the parents and the childs of an specific object, til there everything it's ok, I was able to render the http://demos.telerik.com/aspnet-ajax/diagram/examples/serverside/defaultcs.aspx example on a aspx page without problems, but the problem comes when I try to render the same code inside of a RadWindow, it shows the designated space for the diagram, but completly in blank.
Any help on that matter will be great.
Cheers.
Hi,
I have a contextual menu associated with a tabstrip.
Here's the menu handler:
function
activityContextMenuClicked(sender, args) {
var
itemValue = args.get_item().get_value();
if
(itemValue ==
'new'
) {
openActivityDialog(
'new'
,
''
,
''
,
''
);
}
else
if
(itemValue ==
'edit'
) {
var
tabStrip = $find(
"<%= tbsActivities.ClientID %>"
);
var
tab = tabStrip._findItemByText(args.get_targetElement().innerHTML);
var
activityIDToUpdate = tab.get_value();
var
activityName = tab.get_text();
var
activityDesc = tab.get_attributes().getAttribute(
"Description"
);
openActivityDialog(
'edit'
, activityIDToUpdate, activityName, activityDesc);
}
else
if
(itemValue ==
'delete'
) {
var
tabStrip = $find(
"<%= tbsActivities.ClientID %>"
);
var
tab = tabStrip._findItemByText(args.get_targetElement().innerHTML);
activityIDToDelete = tab.get_value();
radconfirm(
"Are you really sure you want to delete this activity and all of its child elements?"
, deleteActivityResponse, 300, 100,
null
,
"Delete Activity"
,
null
);
}
}
I must mention that the tabstrip is built dynamically, so the text is variable.
The above code works fine unless the text contains an ampersand (I suspect other special characters may cause issues as well).
I tried using findItemByValue(args.get_targetElement().value), but that did not work either.
Any suggestions?
Thanks
Jim
So here is my problem. I am trying to implement of sort of change log that happens during the insert/edit cycle. I can insert the users name and time stamp, but I cannot seem to grab whatever is currently available, add to it, and then return it back. Help would be greatly appreciated.
ASP:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CAF_Detail.aspx.cs" Inherits="DetailViews_CAF_Detail" MasterPageFile="~/EUEMain.master" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"cphLeftNav"
runat
=
"Server"
>
<
asp:HyperLink
ID
=
"HomeLink"
runat
=
"server"
NavigateUrl
=
"..\Default.aspx"
Text
=
"Home"
/>
<%--<
br
/>
<
asp:LinkButton
runat
=
"server"
ID
=
"ImageButton"
Text
=
"Export to Excel"
OnClick
=
"ImageButton_Click"
></
asp:LinkButton
>
<
br
/>--%>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"cphContent"
runat
=
"Server"
>
<
h1
>CAF Tracking System</
h1
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
ShowChooser
=
"true"
/>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
var manager;
Sys.Application.add_load(function () {
manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
});
</
script
>
</
telerik:RadCodeBlock
>
<
script
type
=
"text/javascript"
src
=
"../DetailViews/Scripts.js"
></
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid2"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
>
</
telerik:RadAjaxLoadingPanel
>
<
div
>
<
telerik:RadGrid
ID
=
"RadGrid2"
DataSourceID
=
"SqlDataSource1"
AllowPaging
=
"True"
Width
=
"100%"
runat
=
"server"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
AllowAutomaticInserts
=
"true"
AllowAutomaticUpdates
=
"true"
OnItemDataBound
=
"RadGrid2_ItemDataBound"
OnItemCommand
=
"RadGrid2_ItemCommand"
>
<
MasterTableView
DataKeyNames
=
"Unique"
AutoGenerateColumns
=
"False"
CommandItemDisplay
=
"Top"
DataSourceID
=
"SqlDataSource1"
EditMode
=
"EditForms"
>
<
NestedViewTemplate
>
<
asp:Panel
runat
=
"server"
ID
=
"InnerContainer"
Visible
=
"False"
></
asp:Panel
>
<
telerik:RadMultiPage
runat
=
"server"
ID
=
"Multipage1"
SelectedIndex
=
"0"
RenderSelectedPageOnly
=
"False"
>
<
telerik:RadPageView
runat
=
"server"
ID
=
"Details"
>
<
asp:Label
ID
=
"Label1"
Font-Bold
=
"true"
Font-Italic
=
"true"
Text='<%# Bind("Unique") %>'
Visible="False" runat="server"></
asp:Label
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"SubNotesGrid"
DataSourceID
=
"SqlDataSource3"
ShowFooter
=
"true"
AllowSorting
=
"true"
EnableLinqExpressions
=
"false"
>
<
MasterTableView
ShowHeader
=
"true"
AutoGenerateColumns
=
"False"
AllowPaging
=
"true"
DataKeyNames
=
"Unique, Changelog"
PageSize
=
"25"
HierarchyLoadMode
=
"Client"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Number"
DataField
=
"CAF_Number"
HeaderText
=
"CAF Number"
AllowFiltering
=
"false"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Rev"
DataField
=
"CAF_Rev"
HeaderText
=
"Revision"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Approved"
DataField
=
"CAF_Approved"
HeaderText
=
"Approved"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_System"
DataField
=
"CAF_System"
HeaderText
=
"CAF System"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Build"
DataField
=
"CAF_Build"
HeaderText
=
"Build"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_BNSF"
DataField
=
"CAF_BNSF"
HeaderText
=
"Affecting BNSF"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Desc"
DataField
=
"CAF_Desc"
HeaderText
=
"CAF Description"
AllowFiltering
=
"False"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Post_Date"
DataField
=
"CAF_Post_Date"
HeaderText
=
"Post Date"
DataFormatString
=
"{0:MM/dd/yyyy}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Due_Date"
DataField
=
"CAF_Due_Date"
HeaderText
=
"Due Date"
DataFormatString
=
"{0:MM/dd/yyyy}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"Comments"
DataField
=
"Comments"
HeaderText
=
"Comments"
/>
<
telerik:GridBoundColumn
UniqueName
=
"ChangeLog"
DataField
=
"ChangeLog"
HeaderText
=
"ChangeLog"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings: PtcDbModelEntities %>"
SelectCommand="SELECT * FROM [PtcDbTracker].[dbo].[CAFTable] where [Unique] = @Unique">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"Label1"
Name
=
"Unique"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
</
NestedViewTemplate
>
<
Columns
>
<
telerik:GridEditCommandColumn
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Number"
DataField
=
"CAF_Number"
HeaderText
=
"CAF Number"
AllowFiltering
=
"false"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"CAF_Desc"
DataField
=
"CAF_Desc"
HeaderText
=
"Description"
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"caf_desc"
Text='<%# Bind("CAF_Desc") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:TextBox
runat
=
"server"
ID
=
"CAF_Desc_TextBox"
Width
=
"300px"
Height
=
"75px"
Text='<%# Bind("CAF_Desc") %>' Wrap="True" TextMode="MultiLine"></
asp:TextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"CAF_System"
Visible
=
"False"
HeaderText
=
"System"
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"Label6"
runat
=
"server"
SelectedValue='<%# Bind("CAF_System") %>'
DataSource='<%# (new[] { "OB", "BOS"}) %>'
AppendDataBoundItems="True"
CausesValidation="False">
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
""
>
</
asp:ListItem
>
</
asp:DropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Rev"
DataField
=
"CAF_Rev"
HeaderText
=
"Revision"
Visible
=
"True"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"Comments"
DataField
=
"Comments"
HeaderText
=
"Comments"
AllowFiltering
=
"False"
Visible
=
"False"
>
<
EditItemTemplate
>
<
asp:TextBox
runat
=
"server"
ID
=
"Comments_TextBox"
Width
=
"400px"
Height
=
"150px"
Text='<%# Bind("Comments") %>' Wrap="True" TextMode="MultiLine"></
asp:TextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridDateTimeColumn
UniqueName
=
"CAF_Post_Date"
DataField
=
"CAF_Post_Date"
PickerType
=
"DatePicker"
HeaderText
=
"Post Date"
Visible
=
"False"
/>
<
telerik:GridDateTimeColumn
UniqueName
=
"CAF_Due_Date"
DataField
=
"CAF_Due_Date"
PickerType
=
"DatePicker"
Visible
=
"False"
HeaderText
=
"Due Date"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CAF_Build"
DataField
=
"CAF_Build"
Visible
=
"False"
HeaderText
=
"Build"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"CAF_BNSF"
Visible
=
"False"
HeaderText
=
"Affecting BNSF"
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"Label5"
runat
=
"server"
SelectedValue='<%# Bind("CAF_BNSF") %>'
DataSource='<%# (new[] { "None", "Low", "Medium", "High"}) %>'
AppendDataBoundItems="True"
CausesValidation="False">
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
""
>
</
asp:ListItem
>
</
asp:DropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"CAF_Approved"
DataField
=
"CAF_Approved"
Visible
=
"True"
HeaderText
=
"Approved"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"caf_approved"
Text='<%#Bind("CAF_Approved") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"Label12"
runat
=
"server"
SelectedValue='<%# Bind("CAF_Approved") %>'
DataSource='<%# (new[] { "Approved", "Not Approved"}) %>'
AppendDataBoundItems="True"
CausesValidation="False">
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
""
>
</
asp:ListItem
>
</
asp:DropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridAttachmentColumn
SortExpression
=
"FileName"
UploadControlType
=
"RadAsyncUpload"
DataSourceID
=
"SqlDataSource5"
EditFormHeaderTextFormat
=
"Upload File:"
HeaderText
=
"Attachment Column"
AttachmentDataField
=
"BinaryData"
AttachmentKeyFields
=
"Unique"
FileNameTextField
=
"FileName"
DataTextField
=
"FileName"
UniqueName
=
"AttachmentColumn"
/>
<
telerik:GridBoundColumn
UniqueName
=
"ChangeLog"
DataField
=
"ChangeLog"
HeaderText
=
"ChangeLog"
ReadOnly
=
"True"
Visible
=
"True"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"gridCommand"
></
ClientEvents
>
</
ClientSettings
>
</
telerik:RadGrid
>
<
br
/>
</
div
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings: PtcDbModelEntities %>"
OnInserted="SqlDataSource2_Inserted"
OnUpdated="SqlDataSource2_Updated"
InsertCommand="INSERT INTO [PtcDbTracker].[dbo].[CAFTable] ([CAF_Number], [CAF_System], [CAF_Rev], [CAF_Build], [CAF_BNSF], [CAF_Desc], [Comments], [CAF_Post_Date], [CAF_Due_Date], [BinaryData], [CAF_Approved])
VALUES (@CAF_Number, @CAF_System, @CAF_Rev, @CAF_Build, @CAF_BNSF, @CAF_Desc, @Comments, @CAF_Post_Date, @CAF_Due_Date, @BinaryData, @CAF_Approved) SET @InsertedID = SCOPE_IDENTITY()"
SelectCommand="SELECT * FROM [PtcDbTracker].[dbo].[CAFTable] Order By [CAF_Number] DESC, [CAF_Rev] DESC"
UpdateCommand="UPDATE [PtcDbTracker].[dbo].[CAFTable] SET [CAF_Number] = @CAF_Number
, [CAF_System] = @CAF_System
, [CAF_Rev] = @CAF_Rev
, [CAF_Build] = @CAF_Build
, [CAF_BNSF] = @CAF_BNSF
, [CAF_Desc] = @CAF_Desc
, [Comments] = @Comments
, [CAF_Due_Date] = @CAF_Due_Date
, [CAF_Post_Date] = @CAF_Post_Date
, [CAF_Approved] = @CAF_Approved
WHERE [Unique] = @Unique">
<
DeleteParameters
>
<
asp:Parameter
Name
=
"Unique"
Type
=
"Int32"
></
asp:Parameter
>
</
DeleteParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"CAF_Number"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_System"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Rev"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Build"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_BNSF"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_DESC"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Comments"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Post_Date"
DbType
=
"Date"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Due_Date"
DbType
=
"Date"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"BinaryData"
Type
=
"Byte"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Approved"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"fileName"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ChangeLog"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"InsertedID"
Type
=
"Int32"
Direction
=
"Output"
></
asp:Parameter
>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"CAF_Number"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_System"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Rev"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Build"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_BNSF"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_DESC"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Comments"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Post_Date"
DbType
=
"Date"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CAF_Due_Date"
DbType
=
"Date"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"BinaryData"
Type
=
"Byte"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"fileName"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"CAF_Approved"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ChangeLog"
Type
=
"String"
/>
</
UpdateParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource5"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:PtcDbModelEntities %>"
SelectCommand="SELECT [Unique], [BinaryData] FROM [PtcDbTracker].[dbo].[CAFTable] WHERE [Unique] = @Unique">
<
SelectParameters
>
<
asp:Parameter
Name
=
"Unique"
Type
=
"Int32"
></
asp:Parameter
>
</
SelectParameters
>
</
asp:SqlDataSource
>
</
asp:Content
>
using
System.Text;
using
Telerik.Web.UI;
using
System;
using
xi = Telerik.Web.UI.ExportInfrastructure;
using
System.Web.UI.WebControls;
using
System.Configuration;
using
System.Data.SqlClient;
using
System.IO;
public
partial
class
DetailViews_CAF_Detail : BNSF.EUECommonApplication.EUEBasePage
{
int
fileId;
byte
[] fileData;
string
fileName;
string
mystring1;
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
}
}
protected
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
var editItem = e.Item
as
GridEditFormItem;
if
(editItem !=
null
&& editItem.IsInEditMode)
{
var datePicker = editItem[
"CAF_Post_Date"
].Controls[0]
as
RadDatePicker;
datePicker.Width = Unit.Pixel(100);
var datePicker2 = editItem[
"CAF_Due_Date"
].Controls[0]
as
RadDatePicker;
datePicker2.Width = Unit.Pixel(100);
}
}
protected
void
SqlDataSource2_Inserted(
object
sender, SqlDataSourceStatusEventArgs e)
{
var mystring =
new
StringBuilder(mystring1);
mystring.Append(EUEUser.DisplayName +
' '
+ DateTime.Now);
fileId = (
int
)e.Command.Parameters[
"@InsertedID"
].Value;
UpdateFileData(
"UPDATE [PtcDbTracker].[dbo].[CAFTable] SET [BinaryData] = @BinaryData, [FileName] = @FileName WHERE [Unique] = @Unique"
, fileId, mystring.ToString());
}
protected
void
SqlDataSource2_Updated(
object
sender, SqlDataSourceStatusEventArgs e)
{
var mystring =
new
StringBuilder(mystring1);
mystring.Append(EUEUser.DisplayName +
' '
+ DateTime.Now);
UpdateFileData(
"UPDATE [PtcDbTracker].[dbo].[CAFTable] SET [BinaryData] = @BinaryData, [FileName] = @FileName, [ChangeLog] = @ChangeLog WHERE [Unique] = @Unique"
, fileId, mystring.ToString());
}
private
void
UpdateFileData(
string
command,
int
fileId,
string
mystring)
{
using
(SqlConnection conn =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"PtcDbModelEntities"
].ConnectionString))
{
using
(SqlCommand comm =
new
SqlCommand(command, conn))
{
if
(fileData !=
null
&& fileData.Length > 0)
{
comm.Parameters.Add(
new
SqlParameter(
"Unique"
, fileId));
comm.Parameters.Add(
new
SqlParameter(
"BinaryData"
, fileData));
comm.Parameters.Add(
new
SqlParameter(
"FileName"
, fileName));
comm.Parameters.Add(
new
SqlParameter(
"ChangeLog"
, mystring));
conn.Open();
comm.ExecuteNonQuery();
}
}
}
}
protected
void
RadGrid2_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.UpdateCommandName ||
e.CommandName == RadGrid.PerformInsertCommandName)
{
var item = e.Item
as
GridEditableItem;
if
(!(item
is
GridEditFormInsertItem))
{
fileId = (
int
)item.GetDataKeyValue(
"Unique"
);
mystring1 = (
string
)item.GetDataKeyValue(
"ChangeLog"
);
}
var asyncUpload = item[
"AttachmentColumn"
].Controls[0]
as
RadAsyncUpload;
if
(asyncUpload !=
null
&& asyncUpload.UploadedFiles.Count > 0)
{
var uploadedFile = asyncUpload.UploadedFiles[0];
fileData =
new
byte
[uploadedFile.ContentLength];
fileName = uploadedFile.FileName;
using
(Stream str = uploadedFile.InputStream)
{
str.Read(fileData, 0, (
int
)uploadedFile.ContentLength);
}
}
}
}
}
While using the RadGrid in Batch Mode, I am trying to do some complex client side validation on save. To do so, I am using the ClientEvents-OnCommand to handle it. What I've discovered is that if I cancel the OnCommand event (args.set_cancel(true)) the save is canceled as expected, but when I go to save again (passing validation), what the OnBatchEditCommand command receives on the server side is an UPDATE, not an Insert, and that UPDATE command's newValues and oldValues are both null.
We are currently using version 2014.3.1209.40 I'd like to know if this has been fixed in a newer version before I upgrade our solution, as that will require a full regression test.
Here is my test jig that shows the issue.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestRadGrid.Default" UnobtrusiveValidationMode="None" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
script
src
=
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
type
=
"text/javascript"
></
script
>
<
telerik:RadCodeBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
var isValidatingGrid = false;
function gridCommand(sender, args) {
if (args.get_commandName() !== 'BatchEdit')
return;
var failValidationChk = $('#failValidation');
if (failValidationChk.prop("checked")) {
args.set_cancel(true);
return;
}
else {
//good to save
return;
}
}
</
script
>
</
telerik:RadCodeBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"theScriptManager"
runat
=
"server"
></
asp:ScriptManager
>
<
div
>Fail Validation<
input
id
=
"failValidation"
type
=
"checkbox"
/></
div
>
<
div
>
<
telerik:RadGrid
ID
=
"EventSubjects"
CssClass
=
"eventSubjectsGrid"
AutoGenerateColumns
=
"False"
GridLines
=
"Both"
AllowPaging
=
"True"
PagerStyle-AlwaysVisible
=
"true"
OnNeedDataSource
=
"EventSubjects_NeedDataSource"
OnBatchEditCommand
=
"EventSubjects_BatchEditCommand"
ValidationSettings-EnableValidation
=
"true"
Skin
=
"Sunset"
runat
=
"server"
GroupPanelPosition
=
"Top"
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
ClientEvents
OnCommand
=
"gridCommand"
/>
</
ClientSettings
>
<
MasterTableView
CommandItemDisplay
=
"Bottom"
DataKeyNames
=
"LocationID"
EditMode
=
"Batch"
>
<
BatchEditingSettings
EditType
=
"Cell"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn1"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"MyImageButton"
></
ItemStyle
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"Location"
FilterControlAltText
=
"Filter Location column"
HeaderText
=
"Location"
MaxLength
=
"50"
UniqueName
=
"Location"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"True"
>
<
RequiredFieldValidator
Display
=
"Dynamic"
ForeColor
=
"Red"
ErrorMessage
=
"This field is required"
></
RequiredFieldValidator
>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Barcode"
HeaderText
=
"Barcode"
UniqueName
=
"BarcodeColumn"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"lblBarcode"
Text='<%# Eval("Barcode") %>' ></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtBarcode"
Text='<%# Bind("Barcode") %>'></
asp:TextBox
>
<
asp:CustomValidator
ID
=
"CustomValidatortxtBarcode"
runat
=
"server"
ErrorMessage
=
"Barcode already used"
ControlToValidate
=
"txtBarcode"
Display
=
"Dynamic"
OnServerValidate
=
"CustomValidatortxtBarcode_ServerValidate"
>
</
asp:CustomValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
div
>
</
form
>
</
body
>
</
html
>
Default.aspx.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
namespace
TestRadGrid
{
public
partial
class
Default : System.Web.UI.Page
{
protected
global::System.Web.UI.HtmlControls.HtmlForm form1;
protected
global::System.Web.UI.ScriptManager theScriptManager;
protected
global::Telerik.Web.UI.RadGrid EventSubjects;
public
class
AreaStops
{
public
int
LocationID {
get
;
set
; }
public
string
Location {
get
;
set
; }
public
string
Barcode {
get
;
set
; }
}
public
static
List<AreaStops> s_AreaStopsData =
new
List<AreaStops>();
static
Default()
{
s_AreaStopsData.Add(
new
AreaStops() { LocationID = 1, Location =
"lions"
, Barcode =
"223"
});
s_AreaStopsData.Add(
new
AreaStops() { LocationID = 2, Location =
"tigers"
, Barcode =
"456"
});
s_AreaStopsData.Add(
new
AreaStops() { LocationID = 3, Location =
"bears"
, Barcode =
"789"
});
s_AreaStopsData.Add(
new
AreaStops() { LocationID = 4, Location =
"ducks"
, Barcode =
"123"
});
}
protected
void
Page_Load(
object
sender, EventArgs e){ }
protected
void
EventSubjects_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
EventSubjects.DataSource = s_AreaStopsData;
}
protected
void
EventSubjects_BatchEditCommand(
object
sender, Telerik.Web.UI.GridBatchEditingEventArgs e)
{
System.Diagnostics.Debug.WriteLine(
"Batch update"
);
foreach
(GridBatchEditingCommand curCommand
in
e.Commands)
{
System.Diagnostics.Debug.WriteLine(curCommand.Type);
if
(curCommand.NewValues ==
null
|| curCommand.OldValues ==
null
){
System.Diagnostics.Debug.WriteLine(
"new or old data missing"
);
return
;
}
string
newLocation = (
string
)curCommand.NewValues[
"Location"
];
string
newBarcode = (
string
)curCommand.NewValues[
"Barcode"
];
if
(newBarcode.Contains(
'G'
))
{
e.Canceled =
true
;
curCommand.Canceled =
true
;
return
;
}
if
(curCommand.Type == GridBatchEditingCommandType.Update)
{
AreaStops stop = s_AreaStopsData.FirstOrDefault(ars => ars.LocationID == (
int
)curCommand.OldValues[
"LocationID"
]);
if
(stop !=
null
)
{
stop.Location = newLocation;
stop.Barcode = newBarcode;
}
else
{
s_AreaStopsData.Add(
new
AreaStops() { LocationID = s_AreaStopsData.Count + 1, Location = newLocation, Barcode = newBarcode });
}
}
else
{
s_AreaStopsData.Add(
new
AreaStops() { LocationID = s_AreaStopsData.Count + 1, Location = newLocation, Barcode = newBarcode });
}
}
}
protected
void
CustomValidatortxtBarcode_ServerValidate(
object
source, ServerValidateEventArgs args)
{
bool
isValid = !args.Value.Contains(
'F'
);
args.IsValid = isValid;
}
}
}
I have a asp.net web page with standard Telerik Grids as well as some other Telerik controls such as text box, rich editors etc.
Now currently in order to save data in the form users have to press save in each editable row in the grid after entering data in the row which is the standard grid behavior. In order to save other text fields in the form, they have to press a separate Save button.
Is it possible to have one single save button that can trigger save function in the current row in the grid that is being edited? This single save button will additionally save all the other data in text fields as well.
Additionally users want to be able to have an auto-save feature so form is saved automatically at certain intervals or upon moving away from the page to another page on the site.
i have a page with rad grid and radtabstrip
i want to refresh radgrid from inner tab
note every tab in separate page