Hello,
I read a couple of articles and forum threads about applying a dropdownlist (combobox) as a filter option in RadFilter.
The samples uses a DataSource in the page though, while I want to use the OnNeedDataSource for the grid and the FilterContainerID for the RadFilter to automatically show filter field.
Here is what I got to far, so I don't get any errors:
Code behind:
But like this of course the dropdown doesn't show any values and only the Status filter shows.
If I add FilterContainerID="rgTasks" to the filter of course I get all fields as I want. However when i select the Status field, I get an exception:
This is kind of expected. the filter already is on the page, I add new one. Viewstate gets broken. Dont know the exact detail, but seems logical to me.
My question is, is it possible to achieve what I want? So override the Status filter which is automatically generated from the FilterContainerID="rgTasks" with a custom filter (combobox containing the available values for the Status colum)
Thanks in advance
/yeroon
I read a couple of articles and forum threads about applying a dropdownlist (combobox) as a filter option in RadFilter.
The samples uses a DataSource in the page though, while I want to use the OnNeedDataSource for the grid and the FilterContainerID for the RadFilter to automatically show filter field.
Here is what I got to far, so I don't get any errors:
<
telerik:RadGrid
ID
=
"rgTasks"
runat
=
"server"
OnNeedDataSource
=
"rgTasks_OnNeedDataSource"
EnableViewState
=
"false"
AutoGenerateColumns
=
"false"
Skin
=
"WebBlue"
PageSize
=
"10"
EnableLinqExpressions
=
"true"
AllowPaging
=
"true"
AllowSorting
=
"true"
AllowFilteringByColumn
=
"true"
ShowStatusBar
=
"true"
>
<
PagerStyle
AlwaysVisible
=
"true"
Position
=
"Top"
Width
=
"100%"
/>
<
MasterTableView
DataKeyNames
=
"OID"
ClientDataKeyNames
=
"OID"
IsFilterItemExpanded
=
"false"
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"Startdatum"
SortOrder
=
"Ascending"
/>
</
SortExpressions
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"OID"
HeaderText
=
"OID"
Visible
=
"false"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Volgnummer"
HeaderText
=
"Volgnummer"
Visible
=
"false"
UniqueName
=
"Volgnummer"
AllowFiltering
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Taak"
HeaderText
=
"Dossier"
DataType
=
"System.String"
UniqueName
=
"Taak"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Status"
HeaderText
=
"Status"
DataType
=
"System.String"
UniqueName
=
"Status"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Startdatum"
HeaderText
=
"Startdatum"
HeaderStyle-Width
=
"110px"
DataFormatString="<nobr>{0:dd/MM/yyyy}</
nobr
>" UniqueName="Startdatum" AllowFiltering="true">
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
>
<
ClientEvents
OnRowClick
=
"rowClick"
/>
<
Resizing
AllowColumnResize
=
"true"
/>
<
Selecting
AllowRowSelect
=
"true"
/>
<
DataBinding
EnableCaching
=
"true"
>
</
DataBinding
>
</
ClientSettings
>
</
telerik:RadGrid
>
<
p
>
Filter toepassen:</
p
>
<
br
/>
<
telerik:RadFilter
ID
=
"radFilter"
runat
=
"server"
ExpressionPreviewPosition
=
"Bottom"
OnFieldEditorCreating
=
"RadFilter1_FieldEditorCreating"
OnApplyExpressions
=
"RadFilter1_ApplyExpressions"
Localization-FilterFunctionBetween
=
"Tussen"
Localization-FilterFunctionContains
=
"Bevat"
Localization-FilterFunctionDoesNotContain
=
"Bevat Niet"
Localization-FilterFunctionEndsWith
=
"Eindigt op"
Localization-FilterFunctionEqualTo
=
"Gelijk aan"
Localization-FilterFunctionGreaterThan
=
"Groter dan"
Localization-FilterFunctionGreaterThanOrEqualTo
=
"Groter dan of gelijk aan"
Localization-FilterFunctionIsEmpty
=
"Is Leeg"
Localization-FilterFunctionIsNull
=
"Ongedefinieerd"
Localization-FilterFunctionLessThan
=
"Kleiner dan"
Localization-FilterFunctionLessThanOrEqualTo
=
"Kleiner dan of gelijk aan"
Localization-FilterFunctionNotBetween
=
"Niet tussen"
Localization-FilterFunctionNotEqualTo
=
"Niet gelijk aan"
Localization-FilterFunctionNotIsEmpty
=
"Is niet leeg"
Localization-FilterFunctionNotIsNull
=
"Is niet ongedefinieerd"
Localization-FilterFunctionStartsWith
=
"Begint met"
Localization-GroupOperationAnd
=
"En"
Localization-GroupOperationNotAnd
=
"En niet"
Localization-GroupOperationNotOr
=
"Of niet"
Localization-GroupOperationOr
=
"Of"
AddExpressionToolTip
=
"Expressie toevoegen"
AddGroupToolTip
=
"Groepering toeveoegen"
ApplyButtonText
=
"Toepassen"
BetweenDelimeterText
=
"en"
Culture
=
"nl-NL"
RemoveToolTip
=
"Verwijderen"
ShowLineImages
=
"true"
SettingsFormatter
=
"BinaryFormatter"
>
<
FieldEditors
>
<
custom:radfilterdropdowneditor
datatextfield
=
"Status"
datavaluefield
=
"Status"
fieldname
=
"Status"
datatype
=
"System.String"
displayname
=
"Status"
/>
</
FieldEditors
>
</
telerik:RadFilter
>
Code behind:
protected void rgTasks_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("OID", typeof(long));
dt.Columns.Add("Taak", typeof(string));
dt.Columns.Add("Startdatum", typeof(DateTime));
dt.Columns.Add("Status", typeof(string));
dt.Columns.Add("Volgnummer", typeof(int));
StoredProcedure sp = new StoredProcedure("getAllAanvragen");
sp.addParameter("@regOID", "7");
DataSet ds = sp.executeDataSet();
if (ds != null && ds.Tables.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
DataRow newRow = dt.NewRow();
newRow["OID"] = long.Parse(row["OID"].ToString());
newRow["Taak"] = CommonFunctions.makeDossiernummer(row["Dossiernummer"].ToString(), row["Volgnummer"].ToString());
newRow["Volgnummer"] = int.Parse(row["volgnummer"].ToString());
newRow["Startdatum"] = DateTime.Parse(row["gestartOp"].ToString());
newRow["Status"] = Hive.Util.HiveEnum.getDescription((CommonEnums.AanvraagStatus)row["status"]);
dt.Rows.Add(newRow);
}
}
rgTasks.DataSource = dt;
}
protected void RadFilter1_ApplyExpressions(object sender, RadFilterApplyExpressionsEventArgs e)
{
RadFilterSqlQueryProvider provider = new RadFilterSqlQueryProvider();
provider.ProcessGroup(e.ExpressionRoot);
}
protected void RadFilter1_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)
{
e.Editor = new RadFilterDropDownEditor();
}
But like this of course the dropdown doesn't show any values and only the Status filter shows.
If I add FilterContainerID="rgTasks" to the filter of course I get all fields as I want. However when i select the Status field, I get an exception:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
This is kind of expected. the filter already is on the page, I add new one. Viewstate gets broken. Dont know the exact detail, but seems logical to me.
My question is, is it possible to achieve what I want? So override the Status filter which is automatically generated from the FilterContainerID="rgTasks" with a custom filter (combobox containing the available values for the Status colum)
Thanks in advance
/yeroon