I'm trying to figure out why my first RadGrid with a RadComboBox filter isn't firing when selected.
I've been following the examples online and it doesn't post back.
I'm thinking I need a server side function to force the post back but since the examples didn't have it...
Any ideas? And yes, I disabled Linq for this control.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"server"
>
<
telerik:RadMenu
ID
=
"RadMenu1"
runat
=
"server"
DataNavigateUrlField
=
"Url"
DataSourceID
=
"XmlDataSource1"
DataTextField
=
"Text"
Skin
=
"Windows7"
></
telerik:RadMenu
>
<
asp:XmlDataSource
ID
=
"XmlDataSource1"
runat
=
"server"
DataFile
=
"~/App_Data/XMLFile1.xml"
></
asp:XmlDataSource
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
CellSpacing
=
"0"
DataSourceID
=
"SqlDataSource1"
GridLines
=
"None"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateDeleteColumn
=
"True"
AutoGenerateEditColumn
=
"True"
ShowGroupPanel
=
"True"
Skin
=
"Windows7"
Width
=
"100%"
EnableLinqExpressions
=
"false"
ShowStatusBar
=
"true"
OnPreRender
=
"RadGrid1_PreRender"
>
<
ClientSettings
AllowColumnsReorder
=
"True"
AllowDragToGroup
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
ScrollHeight
=
"500"
/>
</
ClientSettings
>
<
MasterTableView
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"False"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"TABLE_CATALOG"
FilterControlAltText
=
"Filter TABLE_CATALOG column"
HeaderText
=
"TABLE_CATALOG"
ReadOnly
=
"True"
SortExpression
=
"TABLE_CATALOG"
UniqueName
=
"TABLE_CATALOG"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"TABLE_SCHEMA"
FilterControlAltText
=
"Filter TABLE_SCHEMA column"
HeaderText
=
"TABLE_SCHEMA"
ReadOnly
=
"True"
SortExpression
=
"TABLE_SCHEMA"
UniqueName
=
"TABLE_SCHEMA"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderStyle-Width
=
"300"
DataField
=
"TABLE_NAME"
FilterControlAltText
=
"Filter TABLE_NAME column"
HeaderText
=
"TABLE_NAME"
SortExpression
=
"TABLE_NAME"
UniqueName
=
"TABLE_NAME"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
AppendDataBoundItems
=
"true"
DataSourceID
=
"SqlDataSource2"
DataValueField
=
"table_name"
DataTextField
=
"table_name"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("table_name").CurrentFilterValue %>' OnClientSelectedIndexChanged="table_nameChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function table_nameChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("table_name", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"COLUMN_NAME"
FilterControlAltText
=
"Filter COLUMN_NAME column"
HeaderText
=
"COLUMN_NAME"
SortExpression
=
"COLUMN_NAME"
UniqueName
=
"COLUMN_NAME"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ORDINAL_POSITION"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter ORDINAL_POSITION column"
HeaderText
=
"ORDINAL_POSITION"
ReadOnly
=
"True"
SortExpression
=
"ORDINAL_POSITION"
UniqueName
=
"ORDINAL_POSITION"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"COLUMN_DEFAULT"
FilterControlAltText
=
"Filter COLUMN_DEFAULT column"
HeaderText
=
"COLUMN_DEFAULT"
ReadOnly
=
"True"
SortExpression
=
"COLUMN_DEFAULT"
UniqueName
=
"COLUMN_DEFAULT"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"IS_NULLABLE"
FilterControlAltText
=
"Filter IS_NULLABLE column"
HeaderText
=
"IS_NULLABLE"
ReadOnly
=
"True"
SortExpression
=
"IS_NULLABLE"
UniqueName
=
"IS_NULLABLE"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DATA_TYPE"
FilterControlAltText
=
"Filter DATA_TYPE column"
HeaderText
=
"DATA_TYPE"
ReadOnly
=
"True"
SortExpression
=
"DATA_TYPE"
UniqueName
=
"DATA_TYPE"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:masterConnectionString %>" SelectCommand="select * from information_Schema.columns"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:masterConnectionString %>" SelectCommand="select distinct table_name from information_Schema.columns"></
asp:SqlDataSource
>
</
asp:Content
>
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.Skins;
namespace
WebApplication1
{
public
partial
class
WebForm1 : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
string
role = ((TextBox)Master.FindControl(
"TB_Role"
)).Text;
XmlDataSource1.XPath =
string
.Format(
"//Menu[@Role='{0}']/Item"
, role);
}
protected
void
RadGrid1_PreRender(
object
sender, System.EventArgs e)
{
if
(RadGrid1.MasterTableView.FilterExpression !=
string
.Empty)
{
RefreshCombos();
}
}
protected
void
RefreshCombos()
{
SqlDataSource1.SelectCommand = SqlDataSource2.SelectCommand +
" WHERE "
+ RadGrid1.MasterTableView.FilterExpression.ToString();
RadGrid1.MasterTableView.Rebind();
}
}
}