
Jessy Joseph
Top achievements
Rank 1
Jessy Joseph
asked on 01 Dec 2010, 07:24 PM
I have a checkbox column in my radgrid. Is it possible to have filter value as checked when it's loaded. I have shown in the attached image.
Thanks.
Thanks.
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 02 Dec 2010, 05:46 AM
Hello Jessy,
Try the following code snippet to select the CheckBox in GridFilteringItem.
ASPX:
C#:
Thanks,
Princy.
Try the following code snippet to select the CheckBox in GridFilteringItem.
ASPX:
<
telerik:GridCheckBoxColumn
DataField
=
"isapproved"
UniqueName
=
"GridCheckBoxColumn"
>
</
telerik:GridCheckBoxColumn
>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridFilteringItem)
{
GridFilteringItem filterItem = (GridFilteringItem)e.Item;
CheckBox chkbox = (CheckBox)filterItem[
"GridCheckBoxColumn"
].Controls[0];
chkbox.Checked =
true
;
}
}
Thanks,
Princy.
0

Jessy Joseph
Top achievements
Rank 1
answered on 02 Dec 2010, 04:29 PM
It checks the checkbox in the filter column at inital load but still shows the row which is not checked.
<
telerik:GridCheckBoxColumn
DataField
=
"Active"
HeaderText
=
"Active"
SortExpression
=
"Active"
UniqueName
=
"Active"
AutoPostBackOnFilter
=
"true"
ShowFilterIcon
=
"false"
>
</
telerik:GridCheckBoxColumn
>
protected void RadGridCampCreate_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem)
{
GridFilteringItem filterItem = (GridFilteringItem)e.Item;
CheckBox chkbox = (CheckBox)filterItem["Active"].Controls[0];
chkbox.Checked = true;
}
}
0

Princy
Top achievements
Rank 2
answered on 03 Dec 2010, 05:49 AM
Hello Jessy,
You can apply default filter on initial load for a RadGrid control by setting the FilterExpression property of the MasterTableView. And set the CurrentFilterFunction and CurrentFilterValue properties of a column you want to use for filtering.
ASPX:
Also refer the following documentation for more details on this.
Applying default filter on initial load
Thanks,
Princy.
You can apply default filter on initial load for a RadGrid control by setting the FilterExpression property of the MasterTableView. And set the CurrentFilterFunction and CurrentFilterValue properties of a column you want to use for filtering.
ASPX:
<
MasterTableView
FilterExpression
=
"([Active] = 'True')"
>
<
Columns
>
<
telerik:GridCheckBoxColumn
DataField
=
"Active"
UniqueName
=
"Active"
CurrentFilterFunction
=
"EqualTo"
CurrentFilterValue
=
"True"
>
</
telerik:GridCheckBoxColumn
>
. . . . . . . . . .
Also refer the following documentation for more details on this.
Applying default filter on initial load
Thanks,
Princy.
0

Jessy Joseph
Top achievements
Rank 1
answered on 06 Dec 2010, 08:41 PM
Princy when I applied your code it gave me the following error
___________________________________________________________________________________________________________________
Exception Details: Telerik.Web.UI.ParseException: Expression expected
Source Error:
Stack Trace:
--------------------------------------------------------------------------------------------------------------------------------------------------
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"CampaignID"
ClientDataKeyNames
=
"CampaignID"
Width
=
"100%"
CommandItemDisplay
=
"Top"
PageSize
=
"20"
ShowHeadersWhenNoRecords
=
"true"
DataSourceID
=
"dsCampCreate"
FilterExpression
=
"([Active] = 'True')"
>
<
telerik:GridCheckBoxColumn
DataField
=
"Active"
HeaderText
=
"Is Active"
SortExpression
=
"Active"
UniqueName
=
"Active"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"EqualTo"
ShowFilterIcon
=
"false"
CurrentFilterValue
=
"True"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"ImportedFilter"
runat
=
"server"
OnClientSelectedIndexChanged
=
"ImportedFilterSelectedIndexChanged"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Active").CurrentFilterValue %>'
Width="70px" Skin="Outlook">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"Yes"
Value
=
"True"
/>
<
telerik:RadComboBoxItem
Text
=
"No"
Value
=
"False"
/>
<
telerik:RadComboBoxItem
Text
=
"NoFilter"
Value
=
""
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock12"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function ImportedFilterSelectedIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
var filterVal = args.get_item().get_value();
if (filterVal == "True") {
tableView.filter("Active", filterVal, "EqualTo");
}
else if (filterVal == "False") {
tableView.filter("Active", filterVal, "EqualTo");
}
else if (filterVal == "") {
tableView.filter("Active", filterVal, "NoFilter");
}
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridCheckBoxColumn
>
___________________________________________________________________________________________________________________
Expression expected
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: Telerik.Web.UI.ParseException: Expression expected
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
--------------------------------------------------------------------------------------------------------------------------------------------------
0

Jessy Joseph
Top achievements
Rank 1
answered on 06 Dec 2010, 10:02 PM
Finally got the solution to it. Added "EnableLinqExpressions="false" to the grid.
Thanks.
Thanks.