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
I have read, searched and tried different things but cannot get this to work. I have a lot of resources and when you scroll down, the alignment gets more and more off with the appointment rows. So much that you cannot tell where the appointment goes (see attached image). I have my doctype at <!DOCTYPE xhtml strict>. I have removed all styles and css at this point, as nothing was working. I'm trying to start fresh. My RadScheduler is :
<telerik:RadScheduler runat="server" ID="RadScheduler1" GroupBy="FacilityName" GroupingDirection="Vertical"
AppointmentStyleMode="Default" DataKeyField="FacilityReservationKey"
FirstDayOfWeek="Sunday" LastDayOfWeek="Saturday" DataSubjectField="FacilitySubject"
DataStartField="StartTimeOfEvent" DataEndField="EndTimeOfEvent" ShowAllDayRow="false"
SelectedView="TimelineView" Skin="Simple" Height="500px" RowHeight="50px"
OnClientFormCreated="schedulerFormCreated"
CustomAttributeNames="Contact" OnFormCreated="RadScheduler1_FormCreated"
StartEditingInAdvancedForm="true" StartInsertingInAdvancedForm="true">
<TimelineView ColumnHeaderDateFormat="h:mm tt" NumberOfSlots="32" SlotDuration="00:30:00" TimeLabelSpan="2" StartTime="07:00:00" ShowInsertArea="false" />
<Reminders Enabled="false" />
<MonthView UserSelectable="false" />
<DayView UserSelectable="false" />
<WeekView UserSelectable="false" />
<TimelineView UserSelectable="false" />
Thanks so much.
Hello,
I have a radgrid with Batch Edit Mode activated, i have 5 columns: two with one comboBox and three with textBox. I need that one of the radComboBox bind the datasource of the other one attending at the value of the first radcomboBox:
ROW [ txtEtiqueta TextBoxFormato TextBoxAncho RadComboBoxAlineacion RadComboBoxMostrarTipo ]
This is the structure:
<
telerik:RadGrid
ID
=
"RadGridPropiedadesMostrar"
runat
=
"server"
Height
=
"245px"
Width
=
"99%"
Culture
=
"es-ES"
Visible
=
"true"
OnNeedDataSource
=
"RadGridPropiedadesMostrar_NeedDataSource"
OnBatchEditCommand
=
"RadGridPropiedadesMostrar_BatchEditCommand"
OnItemDataBound
=
"RadGridPropiedadesMostrar_OnItemDataBound"
OnPreRender
=
"RadGridPropiedadesMostrar_PreRender"
HeaderStyle-Font-Size
=
"Small"
HeaderStyle-ForeColor
=
"Black"
MasterTableView-NoMasterRecordsText
=
"Sin registros"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
/>
<
Resizing
ResizeGridOnColumnResize
=
"false"
AllowColumnResize
=
"false"
AllowResizeToFit
=
"true"
EnableRealTimeResize
=
"true"
></
Resizing
>
<
Selecting
AllowRowSelect
=
"true"
/>
</
ClientSettings
>
<
MasterTableView
EditMode
=
"Batch"
AutoGenerateColumns
=
"False"
ShowHeadersWhenNoRecords
=
"true"
>
<
BatchEditingSettings
EditType
=
"Cell"
OpenEditingEvent
=
"Click"
/>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"CODIGOMOSTRAR"
DataField
=
"CODIGOMOSTRAR"
HeaderText
=
"CODIGOMOSTRAR"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CODIGOINFORME"
DataField
=
"CODIGOINFORME"
HeaderText
=
"CODIGOINFORME"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
UniqueName
=
"MOS_NOMBRE"
DataField
=
"MOS_NOMBRE"
HeaderText
=
"Nombre"
Visible
=
"false"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"true"
>
<
RequiredFieldValidator
ForeColor
=
"Red"
Text
=
"*This field is required"
Display
=
"Dynamic"
>
</
RequiredFieldValidator
>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"MOS_ETIQUETA"
DataField
=
"MOS_ETIQUETA"
HeaderText
=
"Campo"
Visible
=
"true"
ItemStyle-Width
=
"35%"
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "MOS_ETIQUETA")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtEtiqueta"
runat
=
"server"
Width
=
"85%"
></
telerik:RadTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"MOS_VISIBLE"
DataField
=
"MOS_VISIBLE"
HeaderText
=
"Visible"
Visible
=
"false"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"MOS_FORMATO"
DataField
=
"MOS_FORMATO"
HeaderText
=
"Formato"
Visible
=
"true"
ItemStyle-Width
=
"15%"
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "MOS_FORMATO")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtFormato"
runat
=
"server"
Width
=
"85%"
></
telerik:RadTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"MOS_ANCHO"
DataField
=
"MOS_ANCHO"
HeaderText
=
"Ancho"
Visible
=
"true"
ItemStyle-Width
=
"15%"
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "MOS_ANCHO")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtAncho"
runat
=
"server"
Width
=
"85%"
></
telerik:RadTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"MOS_AINEACION"
DataField
=
"MOS_AINEACION"
HeaderText
=
"Alineación"
Visible
=
"true"
ItemStyle-Width
=
"15%"
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "MOS_AINEACION")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"RadComboBoxAlineacion"
HighlightTemplatedItems
=
"true"
Width
=
"85%"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"MOS_TIPO"
DataField
=
"MOS_TIPO"
HeaderText
=
"Tipo"
Visible
=
"true"
ItemStyle-Width
=
"15%"
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "MOS_TIPO")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"RadComboBoxMostrarTipo"
HighlightTemplatedItems
=
"true"
Width
=
"85%"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
I create the datasource of the RadComboBoxMostrarTipo in PRERENDER like this:
protected void RadGridPropiedadesMostrar_PreRender(object sender, EventArgs e)
{
RadGridPropiedadesMostrar.Rebind();
RadComboBox combo2 = (RadGridPropiedadesMostrar.MasterTableView.GetBatchEditorContainer("MOS_TIPO") as Panel).FindControl("RadComboBoxMostrarTipo") as RadComboBox;
DataTable table2 = new DataTable();
table2.Columns.Add("MOS_TIPO", typeof(int));
table2.Columns.Add("TIPO", typeof(string));
string[] tipos = {"Texto", "Entero", "Doble", "Fecha", "Booleano" };
DataRow row2 = null;
for (int i = 0; i < tipos.Length; i++)
{
row2 = table2.NewRow();
row2["MOS_TIPO"] = i.ToString();
row2["TIPO"] = tipos[i];
table2.Rows.Add(row2);
}
combo2.DataTextField = "TIPO";
combo2.DataValueField = "MOS_TIPO";
combo2.DataSource = table2;
combo2.DataBind();
}
I need to bind the RadComboBoxAlineacion depending of the data loaded in RadComboBoxMostrarTipo when i load each row
Any idea? Thanks!
I have an issue with a Radcombobox. I am trying to set the height of the radcombobox on ClientSelectedIndexChanged, but I am getting a rendering issue and I cannot see where the problem is.
Below, you will find my code;
CSS:
div.RadComboBox_Windows7 .rcbInputCell INPUT.rcbInput
{
height: 37px;
}
ASPX:
<telerik:RadComboBox ID="RCB_Test" runat="server" Width="340px" OnClientSelectedIndexChanged="OnClientSelectedIndexChangedHandler">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Testing please" Value="Testing please" />
<telerik:RadComboBoxItem runat="server" Text="Testing please" Value="Testing please" />
<telerik:RadComboBoxItem runat="server" Text="Testing please" Value="Testing please" />
</Items>
</telerik:RadComboBox>
JavaScript:
function OnClientSelectedIndexChangedHandler(sender, eventArgs) {
var item = sender.get_inputDomElement();
item.style.height = "37px";
I have also attached an image of the problem.
Any help would be appreciated.
}
Hi,
I've implemented the imagegallery in lightbox mode on one of our site and it work fine except when I click on the same image twice, then the image just won't load.
I went to look if it was working on your demo and it doesn't work either.
- Go to : http://demos.telerik.com/aspnet-ajax/image-gallery/examples/functionality/modes/defaultcs.aspx
- Select the LightBox mode.
- Click on an image
- Close the lightbox window with the X in the top right corner
- Click on the same image
The image just don't show up and the loading take forever.
I just want to set the Cache Header "max-age" of ".axd" resources like "Telerik.Web.UI.WebResource.axd","ScriptResource.axd" etc.
So for achieving that I just implemented the IHttpModule and used corresponding Event as in the following code-
"
So just want to know that is this the correct approach or there are some other ways to set Cache Header "max-age" of "axd" resources.