or
<
telerik:RadGrid
ID
=
"RadGridCompanies"
runat
=
"server"
AutoGenerateColumns
=
"False"
DataSourceID
=
"SqlDataSourceCompanies"
GridLines
=
"None"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
CellSpacing
=
"0"
Width
=
"900px"
Skin
=
"Web20"
PageSize
=
"20"
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
EnablePostBackOnRowClick
=
"true"
EnableRowHoverStyle
=
"True"
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"ID, guidid"
DataSourceID
=
"SqlDataSourceCompanies"
CommandItemDisplay
=
"Top"
EditMode
=
"PopUp"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
ShowRefreshButton
=
"False"
></
CommandItemSettings
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
DataType
=
"System.Int32"
HeaderText
=
"ID"
ReadOnly
=
"True"
SortExpression
=
"ID"
UniqueName
=
"ID"
Visible
=
"false"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
></
ModelErrorMessage
>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"guidid"
HeaderText
=
"guidid"
ReadOnly
=
"True"
SortExpression
=
"guidid"
UniqueName
=
"guidid"
Visible
=
"false"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
></
ModelErrorMessage
>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
.... other columns..
<
EditFormSettings
EditFormType
=
"Template"
PopUpSettings-Width
=
"950px"
PopUpSettings-Height
=
"650px"
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
>
</
EditColumn
>
<
FormTemplate
>
<
telerik:RadGrid
ID
=
"RadGridMids"
runat
=
"server"
AllowAutomaticUpdates
=
"false"
OnUpdateCommand
=
"RadGridMids_UpdateCommand"
DataSourceID
=
"SqlDataSourceMids"
GridLines
=
"None"
Skin
=
"Web20"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
Width
=
"800px"
>
<
ClientSettings
EnableRowHoverStyle
=
"True"
>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"ID"
DataSourceID
=
"SqlDataSourceMids"
EditMode
=
"InPlace"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
DataType
=
"System.Int32"
HeaderText
=
"ID"
ReadOnly
=
"True"
UniqueName
=
"ID"
Visible
=
"false"
></
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Bank"
FilterControlAltText
=
"Filter BankName column"
HeaderText
=
"Bank"
SortExpression
=
"Bank"
UniqueName
=
"Bank"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"BankTextBox"
runat
=
"server"
Text='<%# Bind("Bank") %>'></
asp:TextBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"BankLabel"
runat
=
"server"
Text='<%# Eval("Bank") %>'></
asp:Label
>
</
ItemTemplate
>
... other columns...
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Type
=
"OutQuint"
Duration
=
"200"
></
CollapseAnimation
>
</
FilterMenu
>
</
telerik:RadGrid
>
<
asp:Label
ID
=
"lblneedTofindThisLabel"
runat
=
"server"
Text
=
"label to find"
Visible
=
"false"
></
asp:Label
>
</
FormTemplate
>
<
PopUpSettings
Modal
=
"True"
Width
=
"1000px"
/>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
Protected
Sub
RadGridMids_UpdateCommand(sender
As
Object
, e
As
GridCommandEventArgs)
Dim
editedItem
As
GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim
ID_
As
String
= editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)(
"ID"
).ToString()
' .... some logic....
' -- WHAT X should be. ?
Dim
lblneedTofindThisLabel
As
Label = (TryCast(x.FindControl(
"lblneedTofindThisLabel"
), Label))
lblneedTofindThisLabel.visible=true
end sub
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.DataSource = SqlDataSource2;
DropDownList1.DataBind();
}
SetDataSource();
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex > 0)
{
SetDataSource();
RadGrid1.Rebind();
}
}
private void SetDataSource()
{
if (DropDownList1.SelectedIndex > 0)
{
string tableInUse = DropDownList1.SelectedItem.Text;
RadGrid1.DataSource = SqlDataSource1;
SqlDataSource1.DeleteCommand = "DELETE FROM [" + tableInUse + "] WHERE [Id] = @Id";
SqlDataSource1.InsertCommand = "INSERT INTO [" + tableInUse + "] ([Code], [Description], [Bkgroup], [Stgroup], [Quantity], [BomNote], [UnitEng], [AlternCost]) VALUES (@Code, @Description, @Bkgroup, @Stgroup, @Quantity, @BomNote, @UnitEng, @AlternCost)";
SqlDataSource1.SelectCommand = "SELECT prod.Id, prod.Code, prod.Description, prod.Bkgroup, prod.Stgroup, prod.Quantity," +
"prod.BomNote, prod.UnitEng, prod.AlternCost, comp.Unit, comp.Cost, comp.NoteComp " +
"FROM " + tableInUse + " prod " +
"left JOIN Components comp ON comp.Code = prod.Code";
SqlDataSource1.UpdateCommand = "UPDATE [" + tableInUse + "] SET [Code] = @Code, [Description] = @Description, [Bkgroup] = @Bkgroup, [Stgroup] = @Stgroup, [Quantity] = @Quantity, [BomNote] = @BomNote, [UnitEng] = @UnitEng, [AlternCost] = @AlternCost WHERE [Id] = @Id";
}
}
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = SqlDataSource1;
}
protected void Button1_Click(object sender, EventArgs e)
{
RadGrid1.MasterTableView.TableLayout = GridTableLayout.Auto;
RadGrid1.AllowFilteringByColumn = true;
RadGrid1.MasterTableView.AllowFilteringByColumn = true;
RadGrid1.Rebind();
}
protected void Button2_Click(object sender, EventArgs e)
{
RadGrid1.MasterTableView.TableLayout = GridTableLayout.Auto;
RadGrid1.AllowFilteringByColumn = false;
RadGrid1.MasterTableView.AllowFilteringByColumn = false;
RadGrid1.Rebind();
}
protected void RadGrid1_ItemCreated1(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem)
{
GridFilteringItem filteringItem = e.Item as GridFilteringItem;
//set dimensions for the filter textbox
TextBox box = filteringItem["Code"].Controls[0] as TextBox;
box.Width = Unit.Pixel(30);
}
}
<
div
>
<
asp:DropDownList
ID
=
"DropDownList1"
runat
=
"server"
AutoPostBack
=
"True"
AppendDataBoundItems
=
"true"
OnSelectedIndexChanged
=
"DropDownList1_SelectedIndexChanged1"
DataTextField
=
"Name"
DataValueField
=
"Name"
>
<
asp:ListItem
Text
=
"-Select a BOM"
/>
</
asp:DropDownList
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:BOMConnectionString %>" SelectCommand="SELECT [Name] FROM [IndexTabb]"></
asp:SqlDataSource
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
OnClick
=
"Button1_Click"
Text
=
"Filter On"
/>
<
asp:Button
ID
=
"Button2"
runat
=
"server"
OnClick
=
"Button2_Click"
Text
=
"Filter Off"
/>
<
br
/>
<
br
/>
<
br
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
Culture
=
"it-IT"
AllowPaging
=
"True"
AllowSorting
=
"True"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AutoGenerateDeleteColumn
=
"True"
AutoGenerateEditColumn
=
"True"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnItemCreated
=
"RadGrid1_ItemCreated1"
>
<
ExportSettings
ExportOnlyData
=
"True"
>
<
Pdf
PageWidth
=
""
>
</
Pdf
>
</
ExportSettings
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
CommandItemDisplay
=
"Top"
DataKeyNames
=
"Code"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
AllowNaturalSort
=
"False"
>
<
CommandItemSettings
ShowExportToExcelButton
=
"True"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
Text
=
"Delete"
CommandName
=
"Delete"
FilterControlAltText
=
"Filter column1 column"
ConfirmDialogType
=
"RadWindow"
ConfirmText
=
"Do you really want to delete this project and all its content?"
UniqueName
=
"Cancel"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
FilterControlAltText
=
"Filter EditCommandColumn1 column"
></
EditColumn
>
</
EditFormSettings
>
<
PagerStyle
AlwaysVisible
=
"True"
/>
</
MasterTableView
>
<
PagerStyle
AlwaysVisible
=
"True"
/>
</
telerik:RadGrid
>
<
br
/>
<
br
/>
</
div
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:BOMConnectionString %>">
</
asp:SqlDataSource
>
Is there a way that I can conditionally hide a column filter in a RadGrid from the code behind based on the data column name when the RadGrid is set to AutoGenerateColumns="true"?
Example:
I assign a datatable as the RadGrid's datasource. I want to intercept some RadGrid event to see if column "TEST" was added, and if so, then hide the filter for that column in the RadGrid.
Thank you,
-Scott
updateValue:
function
(d){
var
c=$get(
this
._id);
var
e;
var
f=c.value;
if
(c.originalMaxLength){c.maxLength=c.originalMaxLength;
}
if
(
typeof
(d)==
"undefined"
){e=c.value;
<
telerik:RadInputManager
runat
=
"server"
ID
=
"rim"
>
<
telerik:TextBoxSetting
BehaviorID
=
"textRequired"
>
<
Validation
IsRequired
=
"true"
/>
<
TargetControls
>
<
telerik:TargetInput
ControlID
=
"UserName"
/>
<
telerik:TargetInput
ControlID
=
"Password"
/>
</
TargetControls
>
</
telerik:TextBoxSetting
>
</
telerik:RadInputManager
>