I want to delete certains rows based on a condition while binding the grid. I am using the below code. But 'item.Visible = false;'
is not working while 'item.Enabled = false;' is working. Any idea?
protected void userGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
if (item["UserName"].Text.ToString() == "SuperAdmin")
{
item .Visible = false;
// item.Enabled = false;
}
}
}
Hi,
I have a trouble when i try binding a radcolorpicker, because this control does not show the color saved in the database.
What is wrong?
Code .Aspx
<
telerik:RadGrid
id
=
"rgCategoria"
runat
=
"server"
AutoGenerateColumns
=
"False"
AllowAutomaticUpdates
=
"True"
AllowAutomaticInserts
=
"True"
OnNeedDatasource
=
"rgCategoria_NeedDataSource"
Culture
=
"es-ES"
GroupPanelPosition
=
"Top"
OnBatchEditCommand
=
"rgCategoria_BatchEditCommand"
OnItemCommand
=
"rgCategoria_ItemCommand"
OnItemDataBound
=
"rgCategoria_ItemDataBound"
>
<
MasterTableView
DataKeyNames
=
"IdCategoria"
EditMode
=
"Batch"
AutoGenerateColumns
=
"False"
commanditemdisplay
=
"Top"
>
<
commanditemsettings
addnewrecordtext
=
"Nuevo"
cancelchangestext
=
"Cancelar"
refreshtext
=
"Refrescar"
savechangestext
=
"Guardar"
showcancelchangesbutton
=
"True"
showsavechangesbutton
=
"True"
>
</
commanditemsettings
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Nombre"
UniqueName
=
"Nombre"
HeaderText
=
"Nombre"
>
<
HeaderStyle
Width
=
"100px"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Color"
UniqueName
=
"Color"
HeaderText
=
"Color"
>
<
ItemTemplate
>
<
div
style='width: 150px; height: 16px; background-color: <%# Eval("Color") %>'></
div
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadColorPicker
runat
=
"server"
ID
=
"txtColor"
PaletteModes
=
"HSB"
ShowIcon
=
"True"
>
<
Localization
ApplyButtonText
=
"Aplicar"
NoColorText
=
"Ningún Color"
PickColorText
=
"Elegir Color"
WebPaletteTabText
=
"Paleta Web"
BlankColorText
=
"Color Blanco"
CancelButtonText
=
"Cancelar"
CustomColor
=
"Color Personalizado"
HexInputTitle
=
"Código del color hexadecimal "
HSBSliderDragText
=
"Arrastrar"
HSVSliderDragText
=
"Arrastrar"
OkButtonText
=
"Aceptar"
RecentColors
=
"Colores Recientes"
RGBSlidersDecreaseText
=
"Disminuir"
RGBSlidersDragText
=
"Arrastrar"
RGBSlidersIncreaseText
=
"Aumentar"
CurrentColorText
=
"(Color Actual es {0})"
/>
</
telerik:RadColorPicker
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"150px"
>
</
HeaderStyle
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"IdCategoria"
Display
=
"false"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RowVersion"
Display
=
"false"
></
telerik:GridBoundColumn
>
</
Columns
>
<
BatchEditingSettings
EditType
=
"Cell"
OpenEditingEvent
=
"Click"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
Code c#
protected
void
rgCategoria_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
if
(ViewState[
"dtCategoriasColores"
] !=
null
)
{
rgCategoria.DataSource = (DataTable)ViewState[
"dtCategoriasColores"
];
}
else
{
CargarCategoriaColores();
}
}
protected
void
rgCategoria_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem && e.Item.IsInEditMode)
{
GridDataItem editItem = (GridDataItem)e.Item;
RadColorPicker colorLetraRadColorPicker = (RadColorPicker)editItem.FindControl(
"txtColor"
);
colorLetraRadColorPicker.SelectedColor = System.Drawing.ColorTranslator.FromHtml((DataBinder.Eval(e.Item.DataItem,
"Color"
).ToString()));
}
}
protected
void
rgCategoria_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.UpdateCommandName)
{
GridEditableItem editedItem = e.Item
as
GridEditableItem;
RadColorPicker colorRCP = (RadColorPicker)editedItem.FindControl(
"txtColor"
);
if
(colorRCP !=
null
)
colorRCP.SelectedColor = System.Drawing.ColorTranslator.FromHtml((DataBinder.Eval(e.Item.DataItem,
"Color"
).ToString()));
}
}
protected
void
rgCategoria_BatchEditCommand(
object
sender, GridBatchEditingEventArgs e)
{
foreach
(GridBatchEditingCommand command
in
e.Commands)
{
if
((command.Type == GridBatchEditingCommandType.Update))
{
Hashtable newValues = command.NewValues;
Hashtable oldValues = command.OldValues;
string
OrderID = newValues[
"Nombre"
].ToString();
string
ShipName = newValues[
"Color"
].ToString();
}
}
}
hi ,
I want tile list
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17
format.
but now its in
1 2 7 8 13 14
3 4 9 10 15 16
5 6 11 12 17
and i want to remove space between 2 & 7.
So pls give me corrwct answer.
Thanks & Regards,
Radian
Hi All
We're trying to update multiple RadGrid's from the client side after some user activity.
The following code works well:
var
trgAppointments = $find(
"<%=trgAppointments.ClientID%>"
);
trgAppointments.get_masterTableView().rebind();
However, at the same time, we also need to update second Grid on the same page, so we try this:
// Update appointments
var
trgAppointments = $find(
"<%=trgAppointments.ClientID%>"
);
trgAppointments.get_masterTableView().rebind();
// Update progress notes
var
trgProgress = $find(
"<%=trgProgress.ClientID%>"
);
trgProgress.get_masterTableView().rebind();
This doesn't work so well. The end result is:
I'm not sure what the right way to go about this is. Any suggestions?​
I would like to add two files into the radsciptmanager if the user is using a version of IE < 9. My thought is that in the Page_Load I can test the users Browser and use an if statement to add in the 2 scripts. The reason being, these 2 files fix issues in IE 7&8 but they cause issues in IE 9&10. I have posted some code that I have tried out just not sure what I am missing or if it is possible. Is this possible with RadScriptManager? Thanks in advance.
<telerik:RadScriptManager ID="RadScriptManager" runat="server" EnablePartialRendering="true"
AsyncPostBackTimeout="1800" EnableCdn="true">
<Scripts>
<telerik:RadScriptReference Path="~/Scripts/​File1.js" />
<telerik:RadScriptReference Path="~/Scripts/​File2.js" />
<telerik:RadScriptReference Path="~/Scripts/File3.js" />
</Scripts>
</telerik:RadScriptManager>
-------------------------------------------------------------------------------------------------------------------------------
if (type == "IE8" || type == "IE7")
{
RadScriptManager rsmgr = new RadScriptManager();
//ScriptManager smgr = ScriptManager.GetCurrent(Page);
ScriptReference SRef = new ScriptReference("~/Scripts/File4.js");
ScriptReference SRef1 = new ScriptReference("~/Scripts/File5.js");
rsmgr.Scripts.Add(SRef);
rsmgr.Scripts.Add(SRef1);
}​
<%
@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="TelerikRadWindowSample._Default" %>
<%
@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</
asp:Content>
<
asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<telerik:RadWindowManager ID="radWindowManager1" runat="server"></telerik:RadWindowManager>
<h2>
Welcome to ASP.NET!
</h2>
<asp:Button ID="Button1" runat="server" Text="Open Rad Window"
onclick="Button1_Click" />
</p>
</
asp:Content>
here is my code behind
protected
void Button1_Click(object sender, EventArgs e)
{
// I dont see RadAlert
this.radWindowManager1.
}