Binding the Grid on the client

10 posts, 0 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 17 Dec 2008 Link to this post

    Hello,

    I'm trying to bind on the client-side for a grid.  But it's not working; I get the error:

    return

    $find(this._masterClientID);

    Argument can't be null: ID

    _masterClientID is null.

    Why is that?

    Thanks.

     

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Dec 2008 Link to this post

    Hello Brian,

    You can go through the following online demo link in order to assign data source for the grid and refresh its state on the client.
    Client-side data-binding

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 18 Dec 2008 Link to this post

    Hello,

    I am using a web service, instead of the page method approach, but my code is very similar (I don't need to sort or filter, so I left out those parameters).  This is my method:

    function

    bindData(letter) {

     

     

      var grid = $find("<%= rgData.ClientID %>");

     

     

      var view = grid.get_masterTableView();

     

      Services.GetInfoByLetter(letter,

     

        function(results,context) {

     

          context.set_dataSource(results);

          context.dataBind();

        },

     

        function(results, context) {

     

          context.set_dataSource([]);

          context.dataBind();

        },

      view);

    }

    But I get that error...

  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 20 Dec 2008 Link to this post

    Hi Brian,

    Can you please verify that the number of arguments passed to and from your web service methods matches the web service definition and you have properly set the _masterClientID value (I suppose this is the name of your custom javascript variable)? In case you want to retrieve the client id of the master table in the grid, consider using the following syntax:

    var grid = $find("<%= rgData.ClientID %>");
    var view = grid.get_masterTableView();
    var masterId = view.get_element().id;

    Also verify that you set id for the master table explicitly in the grid definition. Alternative, consider switching to declarative client-side binding as demonstrated in this online demo:

    http://demos.telerik.com/aspnet-ajax/Grid/Examples/Client/DeclarativeDataBinding/DefaultCS.aspx

    Best regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 29 Dec 2008 Link to this post

    Hey,

    I'll try that, but actually _masterClientID was in your code; it was erroring in your code for some reason.
  7. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 29 Dec 2008 Link to this post

    Hey,

    Also, for web service calls, do you have to have these parameters:

    [WebMethod(EnableSession=true)]
        public List<MyBusinessObject> GetData(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression)
        {
            ...
        }

    Do you have to have these four parameters?
  8. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 05 Jan 2009 Link to this post

    Hello Brian,

    Yes you must have at least this four parameters on your WebService method if you are using declarative client-side data-binding.
    You can change their names as shown below:
    <ClientSettings> 
      <DataBinding MaximumRowsParameterName=".." SortParameterName=".." /> 
    </ClientSettings> 

    You can find more information here.

    Regards,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 26 Feb 2009 Link to this post

    Hello,

    OK, in that link, i'm using option to to bind, the declarative approach.  I'm trying to do:

    var

    tableView = grid.get_masterTableView();  //errors here; _masterClientID is null (in your code)

     

    tableView.set_dataSource(data);

    tableView.dataBind();

    But when I get the master table view, _masterClientID is null (this is in your code).  I do not know why this is; it was recommended to set an ID on the master table view, but what property woudl that be?  Besides, I do not see a master table view ID in your example...  I'm trying to access it on page load, just like in that example.  For whatever reason, the master table view is null.

    Why?  Thanks.

  10. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 26 Feb 2009 Link to this post

    I should also point out I didn't bind on the server.... does that matter?  And grid does exist, I verified that.
  11. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 04 Mar 2009 Link to this post

    Hello Brian,

    When you are using client-side data-binding of RadGrid(not declarative one) you should have two things in mind:
     - you should bind initially your RadGrid on server
    or
     -
    you should attached ClientSettings.ClientEvents.OnCommand client event

    This way RadGrid will manage to create it's MasterTableView initially and later(on client-side) you will be able to get_masterTableView set_dataSource and call dataBind().

    I hope this helps.

    Regards,
    Nikolay
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017