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

Checkbox Filter Q3 2013

5 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joan
Top achievements
Rank 1
Joan asked on 21 Oct 2013, 02:17 AM
I'm struggling to get a working version of the checkbox filter process.  I write in VB.net.
I have created a web service asmx file but the code in it is never executed.  The code stops in the Javascript with a null object.  Specifically "d" and "f" in the following code blocks are null.
Additonally, the asmx file cannot be referenced by a project as the RadListBoxItemData is a dictionary object which is not supported. This would prevent the service file being part of a services project (my prefered design).

Do you have a working example project written in VB that I could view?

this._filterCancelButton=$telerik.getElementByClassName(this._filterMenu.get_element(),"rgFilterCancel");
this._checkListFilterCancelButtonDelegate=$telerik.addMobileHandler(this,this._filterCancelButton,"click",this._checkListFilterCancelButtonHandler);
}}if(this._checkListFilterKeys&&this._checkListFilterKeys.length>0){this.updateClientState();
}if(this._filterCheckListClientID){var d=$find(this._filterCheckListClientID);
this._checkListItemsRequestedDelegate=Function.createDelegate(this,this._checkListItemsRequestedHandler);
 
d.add_itemsRequested(this._checkListItemsRequestedDelegate);
 
d.add_itemChecked(Function.createDelegate(this,function(m,l){if(m.selectAllFlag){return;
}m.selectAllFlag=true;
if(l.get_item().get_text()=="(Select All)"){if(l.get_item().get_checked()){m.get_items().forEach(function(n){n.check();
});
if(this._filterCheckListClientID){var f=$find(this._filterCheckListClientID);
this._checkListFilterActiveColumn=a;
 
f.get_items().clear();
 
if(a._owner._data.CheckListWebServicePath&&a._data.FilterCheckListWebServiceMethod){f.set_visible(true);
f.get_webServiceSettings().set_path(a._owner._data.CheckListWebServicePath);
f.get_webServiceSettings().set_method(a._data.FilterCheckListWebServiceMethod);

5 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 23 Oct 2013, 12:26 PM
Hi Joan,

The error that you get is not because of the service, but because the RadListBox is not located in the filter menu for some reason. It looks like there is yet another JavaScript error, that breaks the initialization of the control and causes these 2 errors.

Could you confirm that you are using the latest version of our controls and .NET 4.0 or later?
You can see working VB example here:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultvb.aspx?#qsf-demo-source
About the service, you can translate it with this tool: http://converter.telerik.com/

Regards,
Vasil
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Joan
Top achievements
Rank 1
answered on 23 Oct 2013, 12:42 PM
Thanks for replying, Vasil.
I am using the latest version of the controls (as per the subject) and this functionality is new in this release. The project is .Net 4.0. 
How would the RadListBox not be located in the filter menu?  As I see the page, that's exactly where it is.
The Demo in your link uses a C# WCF Service. The VB ASPX page is written as though the C# code is sitting in the same project.
0
Accepted
Vasil
Telerik team
answered on 28 Oct 2013, 12:51 PM
Hi Joan,

I am sorry if my earlier post does not explain good enough what I mean.

The error that you get does not depend on the service. Even if you don't have any service, you should not get such error. It happens to be caused by something else on the page, but I could not say until I test your current code. If it is possible for you, send us an example, that we can run locally.

You can paste the C# code in the code converter and you will receive a VB version.

Regards,
Vasil
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Joan
Top achievements
Rank 1
answered on 11 Dec 2013, 09:41 PM
I now have a working version in VB.  For future reference here is the modified code using an ASMX web service. I haven't shown the code for the ObjectDataSource as I don't believe it adds to this discussion.
Some things to note about the ASMX file.
Don't overlook uncommenting the line <System.Web.Script.Services.ScriptService()>
Some of the Telerik objects cannot be serialized, so the method needs to return an object.  As you can see, I return a list of RadListBoxItemData which is what the grid requires.
I'm also showing here, that you can use Session variables to make user/page items available to the web service. Take a look at the WebMethod attribute.

The ASMX file:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Imports System.ComponentModel
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManager
Imports Telerik.Web.UI
 
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class GridFilterService
    Inherits System.Web.Services.WebService
 
    <WebMethod(enableSession:=True)> _
    Public Function GetStaffLCProcessingTypes() As Object
         Dim ProcessingRegion As String = String.Empty
        If HttpContext.Current.Session("ProcessingRegion") IsNot Nothing Then
            ProcessingRegion = HttpContext.Current.Session("ProcessingRegion").ToString
        End If
        Dim cmd As New SqlCommand
        cmd.Connection = New SqlConnection(ConnectionStrings("MDSConnectionString").ConnectionString)
        cmd.CommandText = "select distinct processing_type"
        cmd.CommandText += " from staffLC"
        cmd.CommandText += " where 1 = 1"
        cmd.CommandText += " and processing_type <> ''"
        cmd.CommandText += " and (processing_region = @ProcessingRegion or @ProcessingRegion = '')"
        cmd.CommandText += " order by 1"
        cmd.Parameters.AddWithValue("@ProcessingRegion", ProcessingRegion)
        Dim dt As New DataTable("stafflc")
        Dim da As New SqlDataAdapter(cmd)
        Dim result As New List(Of RadListBoxItemData)
        Dim item As RadListBoxItemData
        Try
            da.Fill(dt)
            For Each dr As DataRow In dt.Rows
                item = New RadListBoxItemData
                item.Text = dr("processing_type").ToString
                item.Value = item.Text
                result.Add(item)
            Next
            Return result
        Catch ex As Exception
            Throw
        End Try
        Return Nothing
    End Function
End Class

The ASPX file:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="StaffLifeCycle.WebForm1" %>
<!DOCTYPE html>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <div>
            <telerik:RadGrid ID="RadGrid1" runat="server"
                DataSourceID="StaffLCObjectDataSource"
                AutoGenerateColumns="False"
                EnableHeaderContextMenu="True"
                 FilterType="Combined">
                <ClientSettings EnableRowHoverStyle="True"
                    AllowKeyboardNavigation="True">
                    <Selecting AllowRowSelect="True" />
                </ClientSettings>
                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                <GroupingSettings CaseSensitive="false" />
                <MasterTableView DataSourceID="StaffLCObjectDataSource"
                    DataKeyNames="stafflc_id" ClientDataKeyNames="stafflc_id"
                    AllowFilteringByColumn="True" IsFilterItemExpanded="True"
                    CheckListWebServicePath="GridFilterService.asmx"
                    UseAllDataFields="True">
                    <Columns>
                        <telerik:GridBoundColumn
                            HeaderText="Record Number"
                            DataField="stafflc_id"
                            UniqueName="stafflc_id"
                            SortExpression="stafflc_id"
                             ShowFilterIcon="false"
                            CurrentFilterFunction="EqualTo"
                            FilterDelay="200"
                            FilterControlToolTip="Enter the Record Number required">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn
                            HeaderText="Record Type"
                            DataField="processing_type"
                            UniqueName="processing_type"
                            SortExpression="processing_type"
                            FilterCheckListWebServiceMethod="GetStaffLCProcessingTypes"
                            FilterControlToolTip="Use the Filter button to select the record type/s required">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
    </form>
</body>
</html>


0
Joan
Top achievements
Rank 1
answered on 11 Dec 2013, 10:15 PM
Even though I've posted the solution, I cannot mark my post as the answer, so I'll mark Vasil's post above as the answer.
Tags
Grid
Asked by
Joan
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Joan
Top achievements
Rank 1
Share this question
or