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

jQuery Examples

3 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Donald Norris
Top achievements
Rank 1
Donald Norris asked on 07 Mar 2011, 06:16 PM
The coding method you show in your examples $find("<%= RadGrid1.ClientID %>")  errors out when I try it.  Can I use jQuery to do the same thing  $("#RadGrid1").  If this works can you update your examples to show jQuery code in place of the old version?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 10 Mar 2011, 12:07 PM
Hi Donald,

The $find(clientId) method works always, as long as the control you are looking for is not inside a naming container. Additionally, the purpose of our examples is to show the functionality of the controls, not to give advice on how to build your client script. This is up to each developer's choice.

The jQuery library is added to RadGrid since Q3 2008, so you can use it to work with the control on the client-side.

If you want us to help you identify why $find does not work in your scenario, please paste the grid declaration and the mark-up surrounding it and we will inspect where the problem comes from.

All the best,
Tsvetina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Luc
Top achievements
Rank 1
answered on 09 Aug 2011, 04:46 PM
Hello,

How did this issue got resolved?  I've got a similar issue with Internet Explorer 9 in Compatibility Mode.  Here is the code I'm using to reproduce the problem:

Page source (.aspx)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="TestReturnJQuery.TestPage" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!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">
    </telerik:RadScriptManager>
    <telerik:radscriptblock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript" language="javascript" src='<%=Page.ResolveUrl("~/jquery-1.6.2.min.js") %>'></script>
    <script type="text/javascript" language="javascript">
        jQuery.noConflict();
 
        jQuery(document).ready(function () {
            var grid = $find("<%= RadGrid1.ClientID %>");
            // Display random grid property to proof its loaded correctly or generate script error
            alert(grid.UniqueID); 
        });
    </script>
    </telerik:radscriptblock>
    <telerik:RadGrid ID="RadGrid1" runat="server" onneeddatasource="RadGrid1_NeedDataSource" AutoGenerateColumns="true">
    </telerik:RadGrid>
    </form>
</body>
</html>

And here's the code behind (.cs)
namespace TestReturnJQuery
{
   public partial class TestPage : System.Web.UI.Page
   {
      protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
      {
         RadGrid1.DataSource = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
      }
   }
}

I'm using the Q2 2011 of the control (2011.2.712.40).

Take note that I the client needs me to support Compatibility mode, so just ignoring the issue is not a solution.

Thanks
0
Tsvetina
Telerik team
answered on 10 Aug 2011, 04:10 PM
Hi Luc,

The client grid object does not have such property, the one you use is a server property. You could try with:

grid.get_id();

Also, instead of document.ready, it is better to use the pageLoad client event or the grid OnGridCreated event, so that you are sure that the grid object is already created.

All the best,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Donald Norris
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Luc
Top achievements
Rank 1
Share this question
or