Good Day,
I am trying to implement custom filtering on a Radgrid bound to an SQLDataSource with LINQExpressions disabled, however, I cannot seem to get it working on a particular column.
Now, the column in question has "Display='False'" as it's a foreign key column pointing to another table. I've then got another column that's binding to another SQLDataSource to get the actual data. As far as I can tell, this is the approved method of joining multiple tables into one RadGrid...
The problem is that the filterExpression then seems to not be able to see the hidden column. I've also tried filtering on the visible column using both the foreign key and the relevant column from the second table. Neither seems to work. How can I perform filtering on a foreign key column while showing a more pertinent column from the second table?
Also, I'm storing the selected filter variables in the ViewState. Pertinent code below;
1.
<
telerik:GridBoundColumn
DataField
=
"fk1_dID"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter fk1_dID column"
HeaderText
=
"Depot"
SortExpression
=
"fk1_dID"
UniqueName
=
"fk1_dIDo"
Display
=
"False"
ReadOnly
=
"true"
InsertVisiblityMode
=
"AlwaysHidden"
>
2.
</
telerik:GridBoundColumn
>
3.
<
telerik:GridDropDownColumn
FilterControlAltText
=
"Filter column column"
HeaderText
=
"Depot"
SortExpression
=
"fk1_dID"
UniqueName
=
"fk1_dID"
DataField
=
"fk1_dID"
DataSourceID
=
"sqlDepot"
ListTextField
=
"dCode"
ListValueField
=
"dID"
>
4.
<
FilterTemplate
>
5.
<
telerik:RadDropDownList
ID
=
"filterDepot"
runat
=
"server"
DataSourceID
=
"sqlDepot"
DataValueField
=
"dID"
DataTextField
=
"dCode"
OnSelectedIndexChanged
=
"filterDepot_SelectedIndexChanged"
AutoPostBack
=
"true"
AppendDataBoundItems
=
"true"
><
Items
><
telerik:DropDownListItem
Value
=
"0"
Text
=
"All"
/></
Items
></
telerik:RadDropDownList
>
6.
</
FilterTemplate
>
7.
</
telerik:GridDropDownColumn
>
01.
private
string
dateFilter() {
02.
int
y =
int
.Parse(vsYear);
03.
int
m =
int
.Parse(vsMonth);
04.
return
( y != 1990 ? ( m == 0 ? $
"([iDate] >= '{y}-01-01' AND [iDate] <= '{y}-12-31')"
: $
"([iDate] >= '{y}-{string.Format("
{0:0#}
", m)}-01' AND [iDate] <= '{y}-{string.Format("
{0:0#}
", m)}-{DateTime.DaysInMonth(y, m)}')"
) :
""
);
05.
}
06.
private
string
depotFilter() {
07.
return
( vsDepot !=
"00"
? $
"{( vsYear != "
1990
" ? "
AND
" : "
" )}([fk1_dID] = {vsDepot})"
:
""
);
08.
}
09.
private
string
FilterBuilder() {
10.
dAuth.InnerText = $
"{dateFilter()}{depotFilter()}"
;
11.
return
$
"{dateFilter()}{depotFilter()}"
;
12.
}
13.
protected
void
filterDepot_SelectedIndexChanged(
object
sender, DropDownListEventArgs e ) {
14.
vsDepot = e.Text;
15.
rglog.MasterTableView.FilterExpression = $
"{FilterBuilder()})"
;
16.
rglog.MasterTableView.Rebind();
17.
}