문제

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();

    }     
도움이 되었습니까?

해결책

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top