Hello
I have a RadGrid with 3 GridBoundColumn I need to configure the filter of the columns differently.
Ex: column "A" will filter by contain and column "B" will filter by equals.
how to solve it ?. I've tried everything.
thank you
I have a RadGrid with 3 GridBoundColumn I need to configure the filter of the columns differently.
Ex: column "A" will filter by contain and column "B" will filter by equals.
how to solve it ?. I've tried everything.
thank you
3 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 15 Mar 2012, 02:13 PM
Hello Thassio,
Review the javascript solution presented in the first code paragraph of the following help documentation which illustrates how to intercept the OnFilterMenuShowing client event of the grid and display different items in the filter menu based on the data type of the column.
Reducing the Filter Menu Options.
Thanks,
Shinu.
Review the javascript solution presented in the first code paragraph of the following help documentation which illustrates how to intercept the OnFilterMenuShowing client event of the grid and display different items in the filter menu based on the data type of the column.
Reducing the Filter Menu Options.
Thanks,
Shinu.
0

Thassio
Top achievements
Rank 1
answered on 15 Mar 2012, 02:24 PM
That code you send works in a different way. But on my case i have one grid with 4 filters for example, and i was looking for some way of change the filter columns separately. For example i have 2 columns(city, country) . The column city, should have a filter that contains a prop Contains, and country column should have a filter Equals To. What i want is, differents filters for differents columns in the same grid.
Thankz in advance.
Thankz in advance.
0

Shinu
Top achievements
Rank 2
answered on 16 Mar 2012, 11:30 AM
Hello Thassio,
Here is the sample code that I tried which worked as expected.
aspx:
JS:
Thanks,
Shinu.
Here is the sample code that I tried which worked as expected.
aspx:
<
telerik:RadGrid
AutoGenerateColumns
=
"false"
ID
=
"RadGrid1"
DataSourceID
=
"SqlDataSource1"
Width
=
"760px"
AllowFilteringByColumn
=
"True"
runat
=
"server"
GridLines
=
"None"
EnableLinqExpressions
=
"false"
>
<
MasterTableView
TableLayout
=
"Auto"
>
<
Columns
>
<
telerik:GridNumericColumn
DataField
=
"OrderID"
HeaderText
=
"OrderID"
SortExpression
=
"OrderID"
UniqueName
=
"OrderID"
FilterControlWidth
=
"40px"
DataType
=
"System.Int64"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
FilterControlWidth
=
"105px"
DataField
=
"ShipName"
HeaderText
=
"ShipName"
SortExpression
=
"ShipName"
UniqueName
=
"ShipName"
DataType
=
"System.String"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnFilterMenuShowing
=
"filterMenuShowing"
/>
</
ClientSettings
>
<
FilterMenu
OnClientShown
=
"MenuShowing"
/>
</
telerik:RadGrid
>
<script type=
"text/javascript"
>
var
column =
null
;
var
column2 =
null
;
function
MenuShowing(sender, args) {
if
(column ==
null
)
return
;
var
menu = sender;
var
items = menu.get_items();
if
(column ==
"OrderID"
) {
var
i = 0;
while
(i < items.get_count()) {
if
(!(items.getItem(i).get_value()
in
{
'EqualTo'
:
''
})) {
var
item = items.getItem(i);
if
(item !=
null
)
item.set_visible(
false
);
}
else
{
var
item = items.getItem(i);
if
(item !=
null
)
item.set_visible(
true
);
} i++;
}
}
if
(column ==
"ShipName"
) {
var
i = 0;
while
(i < items.get_count()) {
if
(!(items.getItem(i).get_value()
in
{
'Contains'
:
''
})) {
var
item = items.getItem(i);
if
(item !=
null
)
item.set_visible(
false
);
}
else
{
var
item = items.getItem(i);
if
(item !=
null
)
item.set_visible(
true
);
} i++;
}
}
column =
null
;
}
function
filterMenuShowing(sender, eventArgs) {
column = eventArgs.get_column().get_uniqueName();
}
</script>
Thanks,
Shinu.