Ivan Crojach Karačić
Ivan Crojach Karačić

Reputation: 1911

Telerik ASP.NET AJAX Grid reference in Javascript

I am using the Telerik RadGrid which has a MasterTableView inside of it.

Currently I have ClientEvents defined in markup

<ClientSettings>
   <ClientEvents OnGridCreated="gridCreated"></ClientEvents>
</ClientSettings>

And then I just handle it in a separate javascript file like this

var masterTableView;

gridCreated = function (sender) {
    masterTableView = sender.get_masterTableView();
};

What I would like to have is a function like

var grid;
initialize = function(gridId)
{
    grid = someFunction(gridId); // this will return me the Telerik Grid like sender above
}

I could then call this function from the .aspx and pass more parameters if needed. Inside the initialize function I would then take the gridId and grab the whole object like I did in the gridCreated function. From there I would then just grab the masterTableView and do things I have to do.

Is this possible to achieve because I would love to keep my markup as small as possible and have the javascript file be as reusable as possible?

Upvotes: 0

Views: 194

Answers (1)

Veselin Vasilev
Veselin Vasilev

Reputation: 3793

If you pass the gridId to a function, you can use the $find(gridId) inside of that function to get an instance of the grid client-side object.

More details here: http://www.telerik.com/help/aspnet-ajax/grid-getting-client-object.html

Upvotes: 1

Related Questions