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

Random jScript and WebService Issues

3 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
LJ
Top achievements
Rank 1
LJ asked on 02 Nov 2010, 12:29 AM
I am trying to use both the RadGrid and RadComboBox elements without much success.  I keep getting periodic jScript errors and cannot seem to get the WebService going with either the Grid or the ComboBox.  I have installed the Telerik controls and tried to follow the examples in the demos and am just frustrated at this point.  Here is my code for the Grid first:
PickRequest.aspx File:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="PickRequest.aspx.vb" Inherits="eRequest.PickRequestGrids.PickRequest" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head id="Head1" runat="server">
    <style type="text/css">
        .desctable
        {
            border-collapse:collapse;
        }
         
        .desctable td, .desctable th
        {
            padding:3px 5px;
            border: 1px solid #94D3D9
        }
    </style>
</head>
<body class="BODY">
    <form runat="server" id="mainForm" method="post">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <!-- content start -->
     
    <div class="bigModule">
        <div class="bigModuleBottom">
            <span class="title">Virtual scrolling and paging with client-side databinding:</span>
            <ul>
                <li>Drag the vertical scroll and release it to navigate to the desired page</li>
            </ul>
        </div>
    </div>
     
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>
     
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
 
        <script type="text/javascript">
        <!--
            function pageLoad(sender, args) {
                toggleLoadingPanel("<%= RadGrid1.ClientID %>", true);
            }
 
            function showLoadingPanel(sender, args) {
                toggleLoadingPanel(sender.get_id(), true);
            }
 
            function hideLoadingPanel(sender, args) {
                toggleLoadingPanel(sender.get_id(), false);
            }
 
            function toggleLoadingPanel(elementId, show) {
                var loadingPanel = $find("LoadingPanel");
                if (show) {
                    loadingPanel.show(elementId);
                }
                else {
                    loadingPanel.hide(elementId);
                }
            }
 
            function handleScrolling(sender, args) {
                //check if the items are scrolled to bottom and get additional items
                if (args.get_isOnBottom()) {
                    var master = sender.get_masterTableView();
                    if (master.get_pageSize() < master.get_virtualItemCount()) {
                        //changing page size causes automatic rebind
                        master.set_pageSize(master.get_pageSize() + 20);
                    }
                }
            }
            -->
        </script>
 
    </telerik:RadCodeBlock>
     
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" PageSize="14" AutoGenerateColumns="false">
        <PagerStyle Mode="NumericPages" />
        <MasterTableView TableLayout="Fixed">
            <Columns>
                <telerik:GridBoundColumn DataField="ereq" HeaderText="eReq" />
                <telerik:GridBoundColumn DataField="Creator" HeaderText="Creator" HeaderStyle-Width="200px" />
                <telerik:GridBoundColumn DataField="Requestor" HeaderText="Requestor" />
                <telerik:GridBoundColumn DataField="Cost" HeaderText="RequestCost" DataFormatString="{0:C2}" />
                <telerik:GridBoundColumn DataField="Created" HeaderText="CreatedOn" />
                <telerik:GridBoundColumn DataField="Status" HeaderText="RequestStatus" />
                <telerik:GridBoundColumn DataField="Vendor" HeaderText="Vendor" />
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Scrolling AllowScroll="True" EnableVirtualScrollPaging="True" UseStaticHeaders="True">
            </Scrolling>
            <DataBinding Location="PickRequest.aspx" SelectMethod="PickRequests" SelectCountMethod="GetRequestCount"
                StartRowIndexParameterName="startRowIndex" MaximumRowsParameterName="maxRows" />
            <ClientEvents
                OnCommand="showLoadingPanel"
                OnDataBound="hideLoadingPanel" />
        </ClientSettings>
    </telerik:RadGrid>
 
    <!-- content end -->
    </form>
</body>
</html>



PickRequest.aspx.vb File:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports Telerik.Web.UI
Imports System.Collections.Generic
Imports System.Web.Services
Imports eReqBiz
 
Namespace PickRequestGrids
    Partial Public MustInherit Class PickRequest
        Inherits System.Web.UI.Page
        Dim log As New Logging
 
 
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
                Dim bizRules As New eReqBiz.BizRules
 
                Dim ret As List(Of RequestList) = New List(Of RequestList)
                'Dim [select] As String = "SELECT ID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock FROM LargeProducts WHERE ID > @StartIndex AND ID <= @EndIndex"
                Dim curUser As String = Session("UID")
                'Dim parameters As New Dictionary(Of String, Object)()
                'parameters("StartIndex") = Math.Max(startRowIndex, 0)
                'parameters("EndIndex") = Math.Max(startRowIndex + maxRows, maxRows)
                'Dim data As DataTable = ExecuteSelect([select], parameters, ConfigurationManager.ConnectionStrings("TelerikConnectionString").ConnectionString)
                Dim data As DataTable = bizRules.PickEreqs(curUser, "ViewOpen", "PO", "ViewOpen")
                For Each row As DataRow In data.Rows
                    Dim request As New RequestList()
                    request.eReq = DirectCast(row("ereq"), Integer)
                    request.Creator = DirectCast(row("Creator"), String)
                    request.Requestor = DirectCast(row("Requestor"), String)
                    request.Cost = DirectCast(row("Cost"), Decimal)
                    request.Creator = DirectCast(row("Created"), DateTime)
                    request.Status = DirectCast(row("Status"), String)
                    request.Vendor = DirectCast(row("Vendor"), String)
 
                    ret.Add(request)
                Next
 
            Catch ex As Exception
                log.WriteErrorLogEntry(Logging.ErrorType.AppErr, "PickRequest Error = " & ex.ToString)
 
            End Try
 
        End Sub
 
        <WebMethod()> _
        Public Shared Function GetRequestCount() As Integer
            Return 50
        End Function
 
        <WebMethod()> _
        Public Shared Function PickRequests(ByVal startRowIndex As Integer, ByVal maxRows As Integer) As IEnumerable(Of RequestList)
            Dim bizProcess As New eReqBiz.Process
            Dim bizRules As New eReqBiz.BizRules
 
            Dim curUser As String = "SYS.LJW" 'Session("UID")
            Dim ret As List(Of RequestList) = New List(Of RequestList)
            'Dim [select] As String = "SELECT ID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock FROM LargeProducts WHERE ID > @StartIndex AND ID <= @EndIndex"
 
            'Dim parameters As New Dictionary(Of String, Object)()
            'parameters("StartIndex") = Math.Max(startRowIndex, 0)
            'parameters("EndIndex") = Math.Max(startRowIndex + maxRows, maxRows)
            'Dim data As DataTable = ExecuteSelect([select], parameters, ConfigurationManager.ConnectionStrings("TelerikConnectionString").ConnectionString)
            Dim data As DataTable = bizRules.PickEreqs(curUser, "ViewOpen", "PO", "ViewOpen")
            For Each row As DataRow In data.Rows
                Dim request As New RequestList()
                request.eReq = DirectCast(row("ereq"), Integer)
                request.Creator = DirectCast(row("Creator"), String)
                request.Requestor = DirectCast(row("Requestor"), String)
                request.Cost = DirectCast(row("Cost"), Decimal)
                request.Creator = DirectCast(row("Created"), DateTime)
                request.Status = DirectCast(row("Status"), String)
                request.Vendor = DirectCast(row("Vendor"), String)
 
                ret.Add(request)
            Next
 
            Return ret
        End Function
 
        <WebMethod()> _
        Public Shared Function GetOrderCount() As Integer
            Return 200
        End Function
 
        'Private Shared Function ExecuteSelect(ByVal selectCommand As String, ByVal parameters As Dictionary(Of String, Object), ByVal connectionString As String) As DataTable
        '    Dim MySqlConnection As New SqlConnection(connectionString)
        '    Dim MySqlDataAdapter As New SqlDataAdapter()
 
        '    MySqlDataAdapter.SelectCommand = New SqlCommand(selectCommand, MySqlConnection)
 
        '    For Each pair As KeyValuePair(Of String, Object) In parameters
        '        MySqlDataAdapter.SelectCommand.Parameters.Add(New SqlParameter(pair.Key, pair.Value))
        '    Next
 
        '    Dim data As New DataTable()
        '    MySqlConnection.Open()
 
        '    Try
        '        MySqlDataAdapter.Fill(data)
        '    Finally
 
        '        MySqlConnection.Close()
        '    End Try
 
        '    Return data
        'End Function
    End Class
 
    Public Class RequestList
        Private _ereq As Integer
        Private _requestType As String
        Private _requestor As String
        Private _cost As Decimal
        Private _status As String
        Private _vendor As String
        Private _creator As String
        Private _created As DateTime
 
        Public Property eReq() As Integer
            Get
                Return _ereq
            End Get
            Set(ByVal value As Integer)
                _ereq = value
            End Set
        End Property
        Public Property RequestType() As String
            Get
                Return _requestType
            End Get
            Set(ByVal value As String)
                _requestType = value
            End Set
        End Property
        Public Property Requestor() As String
            Get
                Return _requestor
            End Get
            Set(ByVal value As String)
                _requestor = value
            End Set
        End Property
        Public Property Cost() As Decimal
            Get
                Return _cost
            End Get
            Set(ByVal value As Decimal)
                _cost = value
            End Set
        End Property
        Public Property Status() As String
            Get
                Return _status
            End Get
            Set(ByVal value As String)
                _status = value
            End Set
        End Property
        Public Property Vendor() As String
            Get
                Return _vendor
            End Get
            Set(ByVal value As String)
                _vendor = value
            End Set
        End Property
        Public Property Creator() As String
            Get
                Return _creator
            End Get
            Set(ByVal value As String)
                _creator = value
            End Set
        End Property
        Public Property Created() As DateTime
            Get
                Return _created
            End Get
            Set(ByVal value As DateTime)
                _created = value
            End Set
        End Property
    End Class
 
 
End Namespace

3 Answers, 1 is accepted

Sort by
0
LJ
Top achievements
Rank 1
answered on 02 Nov 2010, 12:41 AM
Sorry, I forgot to add what some of the random errors I am getting are.  Sometimes, I will get a Object Doesn't Support this Method ... and this line is highlighted as the problem:
var a=g?new h(g):new h
Sometimes, I will get the "Telerik is not defined" error (although that hasn't happened in awhile.  And additionally, I can't get the Grid to load any data.
0
LJ
Top achievements
Rank 1
answered on 02 Nov 2010, 11:31 AM
I have tried to scale it down in hopes of coming up with a starting point, but still getting a javascript error:

Here is the aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="PickRequest.aspx.vb" Inherits="eRequest.PickRequest" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
 
    <div>
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>
     
    <Telerik:RadGrid id="RadGrid1" runat="server">
   <MasterTableView AutoGenerateColumns="True" />
</Telerik:RadGrid>
    </div>
    </form>
</body>
</html>


Here is the vb code behind:
Imports Telerik.Web.UI
Public Class PickRequest
    Inherits System.Web.UI.Page
    Dim log As New Logging
    Dim bizRules As New BizRules
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
    End Sub
    Private Sub RadGrid1_NeedDataSource(ByVal [source] As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        Dim pickTable As New DataTable
        Try
            Dim curUser As String = Session("UID")
            pickTable = bizRules.PickEreqs(curUser, "ViewOpen", "PO", "ViewOpen")
            RadGrid1.DataSource = pickTable.DefaultView
 
        Catch ex As Exception
            log.WriteErrorLogEntry(Logging.ErrorType.AppErr, "PickRequest Error = " & ex.ToString)
        End Try
 
 
    End Sub 'RadGrid1_NeedDataSource
End Class

The error is am getting is this:
var a=g?new h(g):new h

The data does load if I choose Continue when I get the js error, so databinding seems to be working (none of the other RadGrid features work though)
I have made sure that EnableEmbeddedScripts was set to True:

0
Maria Ilieva
Telerik team
answered on 05 Nov 2010, 10:29 AM
Hello,

The provided code snippets look ok to me and it is not clear what exactly is causing the mentioned error. As the provided information is not enough to isolate the root cause of the issue you are facing, please prepare a simple, fully runnable reproduction demo, open a new support ticket and send it to us along with very detailed reproduction steps and explanations and we will debug it locally and we will do our best to help.
 


Regards,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
LJ
Top achievements
Rank 1
Answers by
LJ
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or