Hi,
in the following test project I'm trying to set 2 filters one after the other. But as soon as one is set the other doesnt apply anymore!
Is there a way to have them both apply?
Thanks in advance.
Christian
in the following test project I'm trying to set 2 filters one after the other. But as soon as one is set the other doesnt apply anymore!
Is there a way to have them both apply?
Thanks in advance.
Christian
Public
Class
MyCustomBoundColumn
Inherits
GridBoundColumn
Public
dsDataSource
As
DataTable
Public
Function
GetDataTable(
ByVal
strColumnName
As
String
)
As
DataTable
Dim
disctinctValues
As
DataTable =
Nothing
If
TypeOf
(dsDataSource)
Is
DataTable
Then
Dim
View
As
New
DataView(dsDataSource)
disctinctValues = View.ToTable(
True
, strColumnName)
End
If
Return
disctinctValues
End
Function
Protected
Overrides
Sub
SetupFilterControls(
ByVal
cell
As
TableCell)
Dim
rcBox
As
New
RadComboBox()
rcBox.ID =
"cboFilter"
&
Me
.DataField
rcBox.DataTextField =
Me
.DataField
rcBox.DataValueField =
Me
.DataField
rcBox.AutoPostBack =
False
AddHandler
rcBox.SelectedIndexChanged,
AddressOf
rcBox_SelectedIndexChanged
Dim
table
As
DataTable = GetDataTable(
Me
.DataField)
Dim
row
As
DataRow = table.NewRow()
row(
Me
.DataField) =
""
table.Rows.InsertAt(row, 0)
rcBox.DataSource = table
cell.Controls.Add(rcBox)
End
Sub
Protected
Overrides
Sub
SetCurrentFilterValueToControl(
ByVal
cell
As
TableCell)
If
Not
(
Me
.CurrentFilterValue =
""
)
Then
DirectCast
(cell.Controls(0), RadComboBox).Items.FindItemByText(
Me
.CurrentFilterValue).Selected =
True
End
If
End
Sub
Protected
Overrides
Function
GetCurrentFilterValueFromControl(
ByVal
cell
As
TableCell)
As
String
Dim
currentValue
As
String
=
DirectCast
(cell.Controls(0), RadComboBox).SelectedItem.Value
Me
.CurrentFilterFunction =
If
((currentValue <>
""
), GridKnownFunction.EqualTo, GridKnownFunction.NoFilter)
Return
currentValue
End
Function
Private
Sub
rcBox_SelectedIndexChanged(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
DirectCast
(
DirectCast
(sender, RadComboBox).Parent.Parent, GridFilteringItem).FireCommandEvent(
"Filter"
,
New
Pair())
End
Sub
End
Class
Imports
Telerik.Web.UI
Imports
System.Data
Imports
System.Web.UI
Imports
System.Web.UI.WebControls
Imports
System.Data.SqlClient
Imports
System.Configuration
Public
Class
_Default
Inherits
System.Web.UI.Page
Public
myDataTable
As
DataTable
Private
Sub
Page_Load(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Load
GetDataTable()
Dim
myColumn
As
MyCustomBoundColumn
myColumn =
New
MyCustomBoundColumn
myColumn.DataField =
"name"
myColumn.HeaderText =
"name"
myColumn.dsDataSource = myDataTable
gvDataTable.MasterTableView.Columns.Add(myColumn)
myColumn =
New
MyCustomBoundColumn
myColumn.DataField =
"mandant_name"
myColumn.HeaderText =
"mandant_name"
myColumn.dsDataSource = myDataTable
gvDataTable.MasterTableView.Columns.Add(myColumn)
End
Sub
Private
Sub
GetDataTable()
Dim
ConnString
As
String
= ConfigurationManager.ConnectionStrings(
"MyConnectionString"
).ConnectionString
Dim
MySqlConnection
As
New
SqlConnection(ConnString)
Dim
MySqlDataAdapter
As
New
SqlDataAdapter()
MySqlDataAdapter.SelectCommand =
New
SqlCommand(
"SELECT * FROM getUser"
, MySqlConnection)
MySqlConnection.Open()
Try
myDataTable =
New
DataTable
MySqlDataAdapter.Fill(myDataTable)
Finally
MySqlConnection.Close()
End
Try
End
Sub
Private
Sub
gvDataTable_NeedDataSource(sender
As
Object
, e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
gvDataTable.NeedDataSource
gvDataTable.DataSource = myDataTable
End
Sub
End
Class
<
form
id
=
"form1"
runat
=
"server"
style
=
"height:100%; width:100%;margin: 0px;padding: 0px;"
>
<
asp:ToolkitScriptManager
ID
=
"ToolkitScriptManager1"
ScriptMode
=
"Release"
EnableScriptLocalization
=
"true"
EnableScriptGlobalization
=
"true"
CombineScripts
=
"false"
runat
=
"server"
EnablePartialRendering
=
"true"
>
</
asp:ToolkitScriptManager
>
<
asp:UpdatePanel
runat
=
"server"
ID
=
"upaDT"
UpdateMode
=
"Conditional"
ChildrenAsTriggers
=
"true"
>
<
ContentTemplate
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"set filter"
AutoPostBack
=
"true"
>
</
telerik:RadButton
>
<
telerik:RadGrid
ID
=
"gvDataTable"
runat
=
"server"
AutoGenerateColumns
=
"false"
Height
=
"600px"
AllowSorting
=
"true"
AllowFilteringByColumn
=
"true"
EnableLinqExpressions
=
"false"
>
<
MasterTableView
DataKeyNames
=
"guid"
ClientDataKeyNames
=
"guid"
AllowFilteringByColumn
=
"true"
EnableColumnsViewState
=
"false"
>
</
MasterTableView
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
>
<
ClientEvents
/>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
ContentTemplate
>
</
asp:UpdatePanel
>
</
form
>