I have a combobox as filter in RadGrid. The combobox has "Alle"(all), "Nein"(no), "Ja"(yes) . The "Alle" was default. The page shows all 75 rows after loaded.
I want to have "Ja" as default and to show the 73 rows with "Ja". So I added OnLoad="cboFilterFormActive_Load" in the RadComboBox and a C# method cboFilterFormActive_Load(...).
The aspx code now is like:
<telerik:RadGrid ID="radGridForms" runat="server"
DataSourceID="SqlDataSource_Grid" AllowSorting="true" AllowPaging="true" PageSize="10" AllowFilteringByColumn="true"
OnDataBound="radGridForms_DataBound">
<MasterTableView AutoGenerateColumns="false" AllowMultiColumnSorting="true">
<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />
<Columns>
<telerik:GridTemplateColumn DataField="FormKey" UniqueName="FormKey">
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="visible" HeaderText="aktiv" UniqueName="FormActive">
<FilterTemplate>
<telerik:RadComboBox ID="cboFilterFormActive" runat="server" RenderMode="Lightweight"
Skin="Bootstrap" Width="100%" ToolTip="Filter Formular aktiv"
DataSourceID="SqlDataSource_FilterFormActive" DataTextField="visible" DataValueField="visible"
AppendDataBoundItems="false"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("FormActive").CurrentFilterValue %>'
OnClientSelectedIndexChanged="visibleComboIndexChanged"
OnItemDataBound="cboFilterFormActive_ItemDataBound"
OnLoad="cboFilterFormActive_Load">
</telerik:RadComboBox>
<telerik:RadScriptBlock ID="RadScriptBlockFilterVisible" runat="server">
<script type="text/javascript">
function visibleComboIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("FormActive", args.get_item().get_value(), "EqualTo");
}
</script>
</telerik:RadScriptBlock>
</FilterTemplate>
<ItemTemplate>
<asp:Label ID="lblFormVisible" runat="server" Text='<%# translateBool(Eval("visible")) %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<PagerStyle Position="TopAndBottom" AlwaysVisible="true" />
</MasterTableView>
<SortingSettings SortedBackColor="#EDEDED" EnableSkinSortStyles="false"></SortingSettings>
<FilterMenu Skin="Bootstrap" EnableEmbeddedSkins="false" RenderMode="Lightweight"></FilterMenu>
</telerik:RadGrid>
a new mothod in aspx.cs:
protected void cboFilterFormActive_Load(object sender, EventArgs e)
{
var combo = (RadComboBox)sender;
RadComboBoxItem itm = combo.FindItemByText("Ja");
if (itm !=null)
itm.Selected = true;
}
The "Ja" is now default in the Combobox. But it doesn't filter. All the 75 values are shown after loading page. How can I make it filter "Ja" out?