Hi,
MasterTableView.ExportToExcel(),MasterTableView.ExportToCSV() etc are not working with Mozilla in the following scenario.
I paced the image buttons inside
<telerik:RadGrid>
<MasterTableView>
<CommandItemTemplate>
<asp:ImageButton.....>
The same is working with Internet Explorer.
How can I make this work keeping the buttons inside <CommandItemTemplate>?
Thanks...
MasterTableView.ExportToExcel(),MasterTableView.ExportToCSV() etc are not working with Mozilla in the following scenario.
I paced the image buttons inside
<telerik:RadGrid>
<MasterTableView>
<CommandItemTemplate>
<asp:ImageButton.....>
The same is working with Internet Explorer.
How can I make this work keeping the buttons inside <CommandItemTemplate>?
Thanks...
4 Answers, 1 is accepted
0

Jayesh Goyani
Top achievements
Rank 2
answered on 30 Jul 2011, 08:46 AM
hi,
please check below code.
if you used Ajax in page then also add below code.
let me know if any concern
Thanks,
Jayesh Goyani
please check below code.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
PageSize
=
"4"
AutoGenerateColumns
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
Skin
=
"Vista"
>
<
MasterTableView
PagerStyle-AlwaysVisible
=
"true"
CommandItemDisplay
=
"Top"
>
<
CommandItemTemplate
>
<
asp:ImageButton
CommandName
=
"ExportToExcel"
ID
=
"btnExportToExcel"
runat
=
"server"
ImageUrl
=
"http://t0.gstatic.com/images?q=tbn:ANd9GcT4E0lInPHLb5tfb9Tf0UhyP35MHGp4eQQKmy5jNjTnKMTwh3aWtA"
/>
</
CommandItemTemplate
>
</
MasterTableView
>
</
telerik:RadGrid
>
if you used Ajax in page then also add below code.
<
script
type
=
"text/javascript"
>
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("btnExportToExcel") >= 0) {
args.set_enableAjax(false);
}
}
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
ClientEvents
OnRequestStart
=
"onRequestStart"
/>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
let me know if any concern
Thanks,
Jayesh Goyani
0

Winni
Top achievements
Rank 1
answered on 01 Aug 2011, 06:11 AM
Hi Jayesh,
Thank you very much for the solution .It is working now.
But now print is not working .Same as export print also got invoked on click of an image button placed in CommandItemTemplate.I am passing radGrid client id from code behind to the function PrintRadGrid. The argument value is coming correctly to the function from code behind but the first line assigns a null value to the var radGrid.var radGrid = $find(radGridId); The print functions are given below.
Thank you very much for the solution .It is working now.
But now print is not working .Same as export print also got invoked on click of an image button placed in CommandItemTemplate.I am passing radGrid client id from code behind to the function PrintRadGrid. The argument value is coming correctly to the function from code behind but the first line assigns a null value to the var radGrid.var radGrid = $find(radGridId); The print functions are given below.
function getOuterHTML(obj) {
if (typeof (obj.outerHTML) == "undefined") {
var divWrapper = document.createElement("div");
var copyOb = obj.cloneNode(true);
divWrapper.appendChild(copyOb);
return divWrapper.innerHTML
}
else
return obj.outerHTML;
}
function PrintRadGrid(radGridId) {
var radGrid = $find(radGridId);
var previewWnd = window.open('about:blank', '', '', false);
var sh = '<%# ClientScript.GetWebResourceUrl(grdName.GetType(),String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css",grdName.Skin)) %>';
var styleStr = "<
html
><
head
><
link
href
=
'" + sh + "'
rel
=
'stylesheet'
type
=
'text/css'
></
link
></
head
>";
var htmlcontent = styleStr + "<
body
>" + getOuterHTML(radGrid.get_element().parentNode) + "</
body
></
html
>";
previewWnd.document.open();
previewWnd.document.write(htmlcontent);
previewWnd.document.close();
previewWnd.print();
previewWnd.close();
radGrid.get_masterTableView().fireCommand("EnablePaging", "");
}
Please suggest a solution .Thanks..
0

Shinu
Top achievements
Rank 2
answered on 01 Aug 2011, 08:19 AM
Hello Soumya,
Take a look at the Code-Library which demonstrates how to print RadGrid contents.
Print RadGrid contents..
Thanks,
Shinu.
Take a look at the Code-Library which demonstrates how to print RadGrid contents.
Print RadGrid contents..
Thanks,
Shinu.
0

Winni
Top achievements
Rank 1
answered on 01 Aug 2011, 08:29 AM
Thanks Shinu...But I followed this link only and it is working fine in IE.
if the buttons are in CommandItemTemplate , then was working for Mozilla(for OuterHTML added seperate function).But when I used the below given code ,print is not working . Print preview is a blank page.
I used the below code as my export to excel,pdf etc was not working.
if the buttons are in CommandItemTemplate , then was working for Mozilla(for OuterHTML added seperate function).But when I used the below given code ,print is not working . Print preview is a blank page.
I used the below code as my export to excel,pdf etc was not working.
<
script
type
=
"text/javascript"
>
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("btnExportToExcel") >= 0) {
args.set_enableAjax(false);
}
}
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
ClientEvents
OnRequestStart
=
"onRequestStart"
/>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>