Dear Telerik,
We have a RadcomboBox in a filter template and we put an default value using the following code
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
RadGrid1.MasterTableView.FilterExpression = "([UserName] like '" + Session("UserName") + "%' )"
End Sub
Protected Sub RadComboBoxUserName_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemEventArgs)
If Not Me.IsPostBack Then
If e.Item.Text = Session("UserName") Then
e.Item.Selected = True
End If
End If
End Sub
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
Runat
=
"Server"
>
<
br
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"False"
EnableLinqExpressions
=
"False"
DataSourceID
=
"SqlDataSource1"
GridLines
=
"None"
Skin
=
"Hay"
PageSize
=
"30"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
OnEditCommand
=
"RadGrid1_EditCommand"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
datakeynames
=
"PMID"
datasourceid
=
"SqlDataSource1"
commanditemdisplay
=
"Top"
PageSize
=
"25"
>
<
RowIndicatorColumn
><
HeaderStyle
Width
=
"20px"
></
HeaderStyle
></
RowIndicatorColumn
>
<
ExpandCollapseColumn
><
HeaderStyle
Width
=
"20px"
></
HeaderStyle
></
ExpandCollapseColumn
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"TemplateColumn"
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"ImageButton1"
runat
=
"server"
AlternateText
=
"Προβολή"
CommandName
=
"Edit"
ImageUrl
=
"~/images/edt.gif"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"PMID"
DataType
=
"System.Decimal"
HeaderText
=
"Κωδικός"
ReadOnly
=
"True"
SortExpression
=
"PMID"
UniqueName
=
"PMID"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CName"
HeaderText
=
"Πελάτης"
SortExpression
=
"CName"
UniqueName
=
"CName"
AndCurrentFilterFunction
=
"Contains"
AutoPostBackOnFilter
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CAddr"
HeaderText
=
"Διεύθυνση"
SortExpression
=
"CAddr"
UniqueName
=
"CAddr"
AndCurrentFilterFunction
=
"Contains"
AutoPostBackOnFilter
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CCity"
HeaderText
=
"Πόλη"
SortExpression
=
"CCity"
UniqueName
=
"CCity"
AndCurrentFilterFunction
=
"Contains"
AutoPostBackOnFilter
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
AutoPostBackOnFilter
=
"True"
DataField
=
"ProposalDate"
DataType
=
"System.DateTime"
HeaderText
=
"Ημερ/νία Προσφοράς"
SortExpression
=
"ProposalDate"
UniqueName
=
"ProposalDate"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"ProposalDateLabel"
runat
=
"server"
Text='<%# Eval("ProposalDate", "{0:dd/MM/yyyy}") %>'></
asp:Label
>
</
ItemTemplate
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
AutoPostBackOnFilter
=
"false"
DataField
=
"PSStatus"
HeaderText
=
"Κατάσταση"
UniqueName
=
"PSStatus"
ReadOnly
=
"True"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboPStatus"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"PSStatus"
DataValueField
=
"PSStatus"
Height
=
"100px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("PSStatus").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="CityIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"'Ολα"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function CityIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("PSStatus", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"UserName"
HeaderText
=
"Χρήστης"
UniqueName
=
"UserName"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxUserName"
DataSourceID
=
"SqlDataSource3"
DataTextField
=
"username"
AutoPostBackOnFilter
=
"false"
DataValueField
=
"username"
Height
=
"200px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("UserName").CurrentFilterValue %>'
runat="server"
OnClientSelectedIndexChanged="TitleIndexChanged"
OnItemDataBound="RadComboBoxUserName_ItemDataBound" >
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"'Ολοι"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function TitleIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("UserName", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
</
Columns
>
<
CommandItemTemplate
>
<
asp:LinkButton
ID
=
"FldNew"
Text
=
"Νέα Προσφορά"
runat
=
"server"
Font-Underline
=
"true"
onclick
=
"FldNew_Click"
Font-Bold
=
"True"
></
asp:LinkButton
>
</
CommandItemTemplate
>
</
MasterTableView
>
<
HeaderStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
ForeColor
=
"White"
Wrap
=
"True"
/>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:AlarmConfigurator %>"
SelectCommand="select * from dbo.ProposalMasterView where DealerCode=@DealerCode order by PMID Desc">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"FldDealerCode"
ConvertEmptyStringToNull
=
"False"
Name
=
"DealerCode"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:HiddenField
ID
=
"FldDealerCode"
runat
=
"server"
/>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:AlarmConfigurator %>"
SelectCommand="select PSID,PSStatus from dbo.StatusMaster">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:AlarmConfigurator %>"
SelectCommand="select username, userID from Users where DealerCode=@DealerCode ">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"FldDealerCode"
Name
=
"DealerCode"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
telerik:RadAjaxManager
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"SqlDataSource2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
</
asp:Content
>
The code works, but the first time we enter a value to another filter item the combo is loosing its default value. Then if manually select an item from the filter combo, it works fine.
Any support to resolve this issue is welcome.
Than you
George