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

Finding the Client ID for a RadGrid inside a RadLightBoxItem tag in a RadLightBox

2 Answers 206 Views
LightBox
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 20 Jul 2016, 01:55 PM

I'm trying to fetch the ClientID for a RadGrid control from client side using JavaScript so that I'll be able to bind data to this from the client side.
The RadGrid is present within the RadLightBox and needs to be populated on a button click event. The markup for LightBox looks something like this.
<telerik:RadLightBox ID="RadLightBox1" runat="server">

<Items><telerik:RadLightBoxItemrunat="server"><ItemTemplate><telerik:RadGrid runat="server" ID="lightbox_radgrid"AutoGenerateColumns="false"><MasterTableView><Columns><%-- Columns not shown here --%> </Columns></MasterTableView><ClientSettings><ClientEvents OnCommand="window_radgrid_OnCommand"/></ClientSettings><GroupingSettings CaseSensitive="false" ShowUnGroupButton="true" /></telerik:RadGrid></ItemTemplate></telerik:RadLightBoxItem></Items></telerik:RadLightBox>

This is the partial Javascript Code that I have written. I am able to find upto the RadLIghtBoxItem element but unable to fetch the RadGrid and it's clientID. This method is to be executed on success of a call to a web service to return the data.
function

onSucessCallThis(result, userContext, methodName)

{

 var radWindow = $find('<%= lightbox.ClientID %>');var LightBoxItems = radWindow.get_items(); console.log(LightBoxItems); console.log(LightBoxItems.get_count());var item = LightBoxItems.getItem(0); console.log(item); //Able to fetch LightBoxItemvar radGrid = item.FindControl("lightbox_radgrid"); //Doesn't work

}

I'm not sure if this is the right way to have a radGrid inside a radLightBox. There isn't many examples of this online.

If the code is unreadable here please check this stackoverflow question

http://stackoverflow.com/questions/38481200/finding-the-client-id-for-a-radgrid-inside-a-radlightboxitem-tag-in-a-radlightbo

2 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 25 Jul 2016, 07:38 AM
Hello,

A possible solution to access the grid on the client is to hook OnShowed client event of RadLightBox and use the findControl of Telerik Static Client Library.
Please check out the following code snippet.
function OnShowed(sender, args)
{
    var grid = $telerik.findControl(sender.get_element(), "lightbox_radgrid");
}

Regards,
Kostadin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Frank
Top achievements
Rank 1
answered on 19 Jan 2018, 01:44 AM

Just FYI, I tried your OnShowed event on the lightbox (which I don't even see on the property tool box), it doesn't do anything.  

 

<telerik:radlightbox id="LBoxEdit" runat="server" width="500px" height="200px" OnShowed="OnShowed"
        modal="true" ShowMaximizeButton="False" ShowRestoreButton="False" RenderMode="Lightweight">

 

 

 

        function OnShowed(sender, args) {
            alert("test");
        }

 

 

I don't even see the message box thus make me think the "onshow" event doesn't even exist.

Tags
LightBox
Asked by
Ben
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Frank
Top achievements
Rank 1
Share this question
or