This is a migrated thread and some comments may be shown as answers.

Radgird Filtering error.

6 Answers 265 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jessy Joseph
Top achievements
Rank 1
Jessy Joseph asked on 01 Dec 2010, 07:13 PM
I have checkbox column in Radgrid. When I filter the Radcombox to "Yes" it gives following error
"Error: Sys.WebForms.PageRequestManagerServerErrorException: Operator '=' incompatible with operand types 'Boolean' and 'Int32' "

My Code
<telerik:GridCheckBoxColumn DataField="Active" HeaderText="Is Active" SortExpression="Active"
  
UniqueName="Active" AutoPostBackOnFilter="true" 
  
CurrentFilterFunction="EqualTo" ShowFilterIcon="false">
  
<FilterTemplate>
  
<telerik:RadComboBox ID="ImportedFilter" runat="server" OnClientSelectedIndexChanged="ImportedFilterSelectedIndexChanged"
  
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Active").CurrentFilterValue %>'
  
Width="70px">
  
<Items>
  
<telerik:RadComboBoxItem Text="NoFilter" Value="" />
  
<telerik:RadComboBoxItem Text="Yes" Value="1" />
  
<telerik:RadComboBoxItem Text="No" Value="0" />
  
</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 == "") {
  
tableView.filter("Active", filterVal, "NoFilter");
  
}
  
else if (filterVal == "1") {
  
tableView.filter("Active", "1", "EqualTo");
  
}
  
else if (filterVal == "0") {
  
tableView.filter("Active", "0", "IsNull");
  
}
  
  
</script>
  
</telerik:RadScriptBlock>
  
</FilterTemplate>
  
</telerik:GridCheckBoxColumn>

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Dec 2010, 09:45 AM
Hello Jessy,

You can achieve the same functionality(Filtering for built-in checkbox column) with the help of following documentation. Here it has used server side approach to achieve this.
Filtering for built-in checkbox column

Thanks,
Princy.
0
Jessy Joseph
Top achievements
Rank 1
answered on 02 Dec 2010, 04:52 PM
Thanks Princy, Is there any solution which I can do it from javascript as I have lot of data to load. So my only worry is that it should not take long time if i do it from server side.  In my filter when I select "No Filter" it works fine. The problem comes when I select "Yes" or "No" it gives an error.
0
Jessy Joseph
Top achievements
Rank 1
answered on 02 Dec 2010, 05:04 PM
It worked when I changed the code to the following . In RadComboBoxItem  Value="True" instead of "1" 

<telerik:GridCheckBoxColumn DataField="Active" HeaderText="Is Active" SortExpression="Active"
UniqueName="Active" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
ShowFilterIcon="false">
<FilterTemplate>
<telerik:RadComboBox ID="ImportedFilter" runat="server" OnClientSelectedIndexChanged="ImportedFilterSelectedIndexChanged"
    SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Active").CurrentFilterValue %>'
    Width="70px">
    <Items>
        <telerik:RadComboBoxItem Text="NoFilter" Value="" />
        <telerik:RadComboBoxItem Text="Yes" Value="True" />
        <telerik:RadComboBoxItem Text="No" Value="False" />
    </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 == "") {
                tableView.filter("Active", filterVal, "NoFilter");
            }
            else if (filterVal == "True") {
                tableView.filter("Active", filterVal, "EqualTo");
            }
            else if (filterVal == "False") {
                tableView.filter("Active", filterVal, "EqualTo");
            }
        
    </script>
  
</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridCheckBoxColumn>





0
Jessy Joseph
Top achievements
Rank 1
answered on 02 Dec 2010, 05:12 PM
The other question is how to make the filter for this column to "Yes" on the initial page load.  And only show the rows which is checked.
0
Shinu
Top achievements
Rank 2
answered on 03 Dec 2010, 06:51 AM
Hello Jessy,


Here I found a relevant documentation that shows how to set filtering for grid on initial page load.
Applying default filter on initial load


Hope this would shed some light on this.


-Shinu.
0
Jessy Joseph
Top achievements
Rank 1
answered on 06 Dec 2010, 10:45 PM
Tags
Grid
Asked by
Jessy Joseph
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jessy Joseph
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or