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

Accessing a div element with jQuery

3 Answers 126 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Margret
Top achievements
Rank 1
Margret asked on 03 Feb 2012, 10:24 AM
Hi.

Is it possible to access a div element with jQuery? I need to write a costum jQuery function
for a "onClick" event in my Report. Within the div I have a picture and when the user clicks
on it, I want to pop-up a window to display the photo.

Screenshot: http://i44.tinypic.com/ok9y5e.jpg

Thanks!

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 06 Feb 2012, 11:04 AM
Hello Margret,

You can set a Hyperlink Action to the PictureBox item that would open another window with the full size image.

All the best,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Margret
Top achievements
Rank 1
answered on 06 Feb 2012, 11:22 AM
Hi Steve.

Thank you for the answer. But I need to open the picture in a jQuery dialog, so I need acccess to the DIV element or is it possible to override the Hyperlink Action so I could use it for my purpose?

Best regards.
0
Steve
Telerik team
answered on 06 Feb 2012, 02:00 PM
Hi Margret,

You cannot override the Hyperlink action. You can however hook up to the OnReportLoaded event of the viewer and do what you need there.

<telerik:ReportViewer ID="ReportViewer1" runat="server"  style="border:1px solid #ccc;" width="99%" height="99%"/>
            <script type="text/javascript">
                ReportViewer.prototype.OnReportLoadedOld = ReportViewer.OnReportLoaded;
                ReportViewer.prototype.OnReportLoaded = function () {
                    this.OnReportLoadedOld();
  
                    var reportFrame = document.getElementById(this.reportFrameID);
                    var reportDocument = reportFrame.contentWindow.document;
                    var body = reportDocument.getElementsByTagName("body")[0];
            //find the div and do what you need
                }
</script>

Note however that in your particular scenario, you want to use the report to "post" some kind of "commands" for your application that are not valid from outside the application. We would suggest extracting these actions from the reports to the application as this way the reports will contain only the relevant information and will be really portable - that is you can export them to PDF or Excel and can open them outside your application.

Regards,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Margret
Top achievements
Rank 1
Answers by
Steve
Telerik team
Margret
Top achievements
Rank 1
Share this question
or