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

Binding the Grid on the client

9 Answers 292 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 18 Dec 2008, 01:32 AM
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.

 

9 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Dec 2008, 04:51 AM
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.
0
Brian Mains
Top achievements
Rank 1
answered on 18 Dec 2008, 02:25 PM
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...

0
Sebastian
Telerik team
answered on 20 Dec 2008, 11:03 AM
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.
0
Brian Mains
Top achievements
Rank 1
answered on 29 Dec 2008, 02:03 PM
Hey,

I'll try that, but actually _masterClientID was in your code; it was erroring in your code for some reason.
0
Brian Mains
Top achievements
Rank 1
answered on 29 Dec 2008, 02:11 PM
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?
0
Nikolay Rusev
Telerik team
answered on 05 Jan 2009, 12:00 PM
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.
0
Brian Mains
Top achievements
Rank 1
answered on 26 Feb 2009, 07:05 PM
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.

0
Brian Mains
Top achievements
Rank 1
answered on 26 Feb 2009, 07:14 PM
I should also point out I didn't bind on the server.... does that matter?  And grid does exist, I verified that.
0
Nikolay Rusev
Telerik team
answered on 04 Mar 2009, 01:26 PM
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.
Tags
Grid
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Brian Mains
Top achievements
Rank 1
Sebastian
Telerik team
Nikolay Rusev
Telerik team
Share this question
or