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
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.
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...
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.
I'll try that, but actually _masterClientID was in your code; it was erroring in your code for some reason.
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?
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.
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.
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.