Help with Ajax enabling a RadGrid

17 posts, 0 answers
  1. Mike
    Mike avatar
    6 posts
    Member since:
    Feb 2009

    Posted 22 Feb 2009 Link to this post

    I am attempting to update the RadGrid using a Ajax.  I am using a non-Telerik control to trigger the update.    I get the following error.


    Script control 'RadGrid1' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
    Parameter name: scriptControl

    I'm a newbie to Ajax.  Am I missing something beside placing a scriptmanager on the page along with the RadGrid?

    Thanks

  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 24 Feb 2009 Link to this post

    Hi Mike,

    A sample page with ajaxified grid should look like the below snippet:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
     
    <%@ 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"> 
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
            <asp:ScriptManager ID="ScriptManager1" runat="server">  
            </asp:ScriptManager> 
            <div>              
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
                    <ContentTemplate> 
                        <telerik:RadGrid ID="RadGrid1" runat="server">  
                            <MasterTableView> 
                                ....  
                            </MasterTableView> 
                        </telerik:RadGrid> 
                    </ContentTemplate> 
                </asp:UpdatePanel> 
            </div> 
        </form> 
    </body> 
    </html> 

    What differs in your case?

    Regards,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mike
    Mike avatar
    6 posts
    Member since:
    Feb 2009

    Posted 26 Feb 2009 Link to this post

    This probably better clarifies my problem better.  It has to do with AJAX interoperability between Telerik and Dundas.     Dundas uses a "callback" method.   This works fine with the standard VisualStudio ASP.NET controls but not with the Telerik controls.

    Here's what I posted to Dundas's forum

    "Hi,  Does anyone know of a work-around for trying to update controls from Telerik when performing an AJAX enabled chart scoll event?

    Example:
    protected void Chart1_ChartScroll(object sender, Dundas.Charting.WebControl.Chart.ChartScrollEventArgs e)
           {
               RadTextBox1.Text = "Updated!";
               Chart1.CallbackManager.UpdateClientControl(RadTextBox1);
              
           }

    UpdateClientControl throws the following error:
    Script control 'RadTextBox1' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().

    I'm not sure if this is a Telerik issue or Dundas but I'm hoping someone has seen this before and figured out a way around it.

    Thanks "

    I tried to resolve this by putting the Rad control in a standard Ajax UpdatePanel but no luck (same error).




  4. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 27 Feb 2009 Link to this post

    Hello Mike,

    RadControls for ASP.NET AJAX are built on top of MS AJAX Framework. I can assure you that our controls are fully compatible with it and RadGrid could be ajaxified either with MS UpdatePanel or via RadAjax.
    In this case I would suggest you to try using MS UpdatePanels mainly instead of the Dundas's ajax and hope this would work.

    All the best,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Mike
    Mike avatar
    6 posts
    Member since:
    Feb 2009

    Posted 27 Feb 2009 Link to this post

    Thank you for replying so quickly.

    I don't feel this is necessarilly a Telerk problem but it is a problem trying to get Dundas Control to work with Telerik.  
    Here's the Dundas method of triggering an Ajax update:
     DundasChart1.CallbackManager.UpdateClientControl(RadGrid1);  
    This method fires the previously mentioned error.  It does not have this issue with Microsoft's Gridview.

    I'll keep working the Dundas forum too but let me know if you having any work arounds to set up the RadGrid (or just about any Rad control I tried)

    Thanks,

    Mike
  6. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 04 Mar 2009 Link to this post

    Hello Mike,

    Can you send me a working sample of your scenario, with MS GridView, for instance. I will debug it locally and perform further investigation what could be the issue with RadGrid and find a resolution for you?

    Thank you for your cooperation in advance

    Greetings,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 06 Jun 2009 Link to this post

    Hey Guys Is There Any Other Way to Trouble Shoot this.
    I Too Have The Same Problem.
    Here is My Sample Cide

    private void rendergrid(RadGrid _grid)
        {
            

            
           
            using (StringWriter sw = new StringWriter())
            {
                HtmlTextWriter htw = new HtmlTextWriter(sw);
                
                _grid.RenderControl(htw);
                htw.Flush();
                returnValue = sw.ToString();
            }
        }

    The Highlighted One Produced the Error For me Threw The Exception
    As it Goes Like This:"Script control 'RadGrid1' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
    Parameter name: scriptControl".

    Plz also Help Me Guys
    Thanks
    Regards
    N.Balaji
  8. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 08 Jun 2009 Link to this post

    Hello balaji,

    Can you try replacing the ASP:ScriptManager on the problematic page with RadScriptManager and see if it makes any difference?

    Greetings,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Mike
    Mike avatar
    6 posts
    Member since:
    Feb 2009

    Posted 08 Jun 2009 Link to this post

    Here's what I posted on the Dundas site awhile back.  This resolved my original post about this issue.
    ----
    After a lot of experimenting I came up with my own solution.  

    Instead of calling updateclientcontrol use a little bit of JScript.

    DundasChart1.CallbackManager.ExecuteClientScript("__doPostBack('" + this.RadGrid1.UniqueID + "','eventarg1$eventarg2')"); 
              
    Works well so far.
  10. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 10 Jun 2009 Link to this post

    Hi Guys i was going thru Rad grid Client insert,delete operations using ajax.
    But while entering new record i cant find the grid getting replicated.
    For Reference:
    http://demos.telerik.com/aspnet-ajax/grid/examples/client/insertupdatedelete/defaultcs.aspx
    For that i tried to insert my sample code in the web services which returned a sample int value.

    Here is the Web service code.

    [WebMethod]
        public int testservice( int employeeid)
        {
            int values = employeeid;
            return values;
        }



    function rowSelected(sender, args) {
                   //employeeID = args.getDataKeyValue("EmployeeID");
                   debugger;
                   employeeID = getDataItemKeyValue(sender, args.get_gridDataItem());
                
                   currentRowIndex = args.get_gridDataItem().get_element().rowIndex;

                   $find("RadTabStrip1").set_selectedIndex(0);

                   var intval = ajaxservice.testservice(employeeID)
                  But Here am Getting undefined value
                   alert(intval);
    //               ajaxservice.GetEmployeeByEmployeeID(employeeID, setValues)
               }
  11. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 11 Jun 2009 Link to this post

    Hi balaji,

    Can you confirm that you have added your webservice as a ServiceReference in the ScriptManager of the problematic page?

    Sincerely yours,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  12. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 11 Jun 2009 Link to this post

    Yes its confirmed iam using The Service Reference Tag in My Page.


  13. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 11 Jun 2009 Link to this post

    Hello balaji,

    Can you send a sample project illustrating your scenario for further investigation? If it is not convenient for you, I can try following your steps and send you a sample for comparison.

    Best wishes,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  14. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 12 Jun 2009 Link to this post

    Well Am using the Same Scenario as it is used in the Demo  no change at all.
    Note that am using vista environment wuld that be a cause for that.
  15. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 15 Jun 2009 Link to this post

    Hi balaji,

    I prepared a runnable sample for you following the mentioned demo. Please try it on your end and let me know what differs in your case and if I missed something from your logic.

    Best wishes,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. M.
    M. avatar
    2 posts
    Member since:
    Sep 2010

    Posted 21 Sep 2010 Link to this post

    Hi Iana,

    may is ask you a favor. Could you help me to understand your example better?
    (see also http://demos.telerik.com/aspnet-ajax/grid/examples/client/insertupdatedelete/defaultcs.aspx)

    In both examples the aspx page has a javascript function updateChanges which calls the webservice:
    function updateChanges() {
        MyWebService.UpdateEmployeeByEmployee(getValues(), updateGrid);
    }

    As you can see two parameters [getValues() and updateGrid] are passed into the UpdateEmployeeByEmployee-Web-Method. But as far as i can tell the webservice-method has only 1 parameter (Employee):

    public EmployeesList UpdateEmployeeByEmployee(Employee employee) {
     
        Employee employeeToUpdate = GetEmployeeByEmployeeID(employee.EmployeeID);
        EmployeesList empList =                 
               (EmployeesList)HttpContext.Current.Session["MyData"];
        // ... more stuff
        HttpContext.Current.Session["MyData"] = empList ;
        return empList;
    }

    I see (now)  that the button SaveChanges fires the js-function updateChanges(). Which calls the Webservice.

    But how does the js-function updateGrid(result) and the Webservice work together since the web method has only 1 parameter employee?

    function updateGrid(result) {
      var tableView = $find("#RadGrid1ClientID").get_masterTableView();
      tableView.set_dataSource(result);
      tableView.dataBind();
                     
      var grid = $find("#RadGrid1ClientID");
      grid.repaint();
    }

    Where is the parameter result defined / filled?

    I do understand most parts but do not understand the whole chain of commands / events.
    Button SaveChanges triggers the js-function updateChanges which calls the webservice UpdateEmployeeByEmployee and passes 2 parameters (instead of 1).

    But how is it possible that UpdateEmployeeByEmployee   takes 2 arguments if the method in the asmx-file / the MyWebService.cs file has only 1 argument.

    And what is the consequence of adding empList to HttpContext?
    HttpContext.Current.Session["MyData"] = empList;

    Since the WebMethod retunrs empList how does this get passed to the RadGrid1 and how does the grid get updated.


    Best regards and thanks a lot
    M.
  17. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 24 Sep 2010 Link to this post

    Hi M.,

    The last/odd parameter of the WebService method call is the name of the javascript method that will receive the returned result. And the result parameter the of the updateGrid method is fed with the result of the WebService method.

    Kind regards,
    Iana
    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
Back to Top