Question

i have a form and some usercontrol that i call 'em dynamicaly .user control has a radGrid[ telerik component] i have radwindows too.i wanna update my grid in usercontrol when user insert or update in rad windows form .i used code below to update gride when windows form close but i get error cuz when main form is loaded has no usercontrol with grid;

    function OnClientClose(sender, args) {
        var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();

        masterTable.rebind();

    }     
Was it helpful?

Solution

1) take a look here: http://www.telerik.com/support/kb/aspnet-ajax/general/using-dynamic-unique-names-for-javascript-functions.aspx.

2) create a unique function that will handle OnClientCLose for each UC instance

3) declare these functions in each user control and wrap them in a RadScriptBlock

this should let yo reference the grid from the user control.

If the window is not in every instance it would be hard to know which grid you need to update. You can set a custom CSS class to the desired grid and use that to access its client-side object:

var grid = $telerik.$(".myCustomClass")[0];
if(grid && grid.control) grid.get_masterTableView().rebind();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top