Hi,
I have been trying to get the copy() function to work for my WebGrid, but it keeps returning false. Here is my javascript code for capturing the context menu:
//Firefox passes event arg as parameter (evt). If that is null, we'll use window.event (Internet Explorer proprietary)
//Call show menu with menuID
//specify clientX and clientY to get more accurate positioning for this particular layout
//Firefox (W3C) - cancel event
//InternetExplorer (Proprietary) - cancel event
return false;
}
{
//Grab a reference to the ContextMenuItem that was clicked on
var oGrid = igtbl_getGridById("ugContacts");
if(item!=null){
//We'll use the text from the menuitem to decide which operation to perform
oGrid.selectRowRegion(oGrid.Rows.getRow(0), oGrid.Rows.getRow(nRows-1));
break;
oGrid.copy();
case "Export To Excel":
//Because the WebGrid consumes all mouse events, we need to add
//a listener to determine when a mouse click has occured so we can
//close the popup menu appropriately
The "Select All" and "Export to Excel" functions properly, but the copy returns a false when I capture it's return value.
I have a WebGrid in a page, it is hierarchical, and I have CellClickActionDefault set to RowSelect. Here is my UltraWebGrid setup:
oninitializelayout="ugContacts_InitializeLayout"
OnDataBinding="ugContacts_DataBinding">
<Bands>
<igtbl:UltraGridBand>
<AddNewRow Visible="NotSet" View="NotSet"></AddNewRow>
</igtbl:UltraGridBand>
</Bands>
name="UltraWebGrid1" rowheightdefault="-1px" selecttypecelldefault="Extended"
viewtype="Hierarchical" CellPaddingDefault="5" ColWidthDefault="-1px" GridLinesDefault="None"
allowsortingdefault="OnClient" enableclientsiderenumbering="True"
sortcasesensitivedefault="False" CellClickActionDefault="RowSelect">
font-names="Microsoft Sans Serif" font-size="XX-Small" height="560px"
width="100%">
</framestyle>
<Images ImageDirectory="./ig_res/Default/images/">
<CollapseImage Url="igg_sortAsc.gif" />
<ExpandImage Url="igg_sortDesc.gif" />
</Images>
Font-Size="XX-Small" BackColor="#CCCCCC" BorderColor="#0144D0"
BorderStyle="None" BorderWidth="0px">
<Padding Left="3px" />
<BorderDetails ColorLeft="White" ColorTop="White" />
</RowAlternateStyleDefault>
<ClientSideEvents MouseUpHandler="ugContacts_MouseUpHandler" />
<pager>
<PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
widthtop="1px" />
</PagerStyle>
</pager>
font-size="XX-Small" Font-Bold="True">
</headerstyledefault>
borderwidth="0px" font-names="Microsoft Sans Serif" font-size="XX-Small">
<padding left="3px" />
<borderdetails colorleft="White" colortop="White" />
</rowstyledefault>
<SelectedRowStyleDefault BackColor="#9FBEEB">
</SelectedRowStyleDefault>
<GroupByBox Hidden="True">
</GroupByBox>
<addnewbox>
Font-Names="Microsoft Sans Serif" Font-Size="XX-Small">
</boxstyle>
</addnewbox>
borderstyle="None">
</activationobject>
<AddNewRowDefault>
<RowStyle Font-Names="Microsoft Sans Serif" Font-Size="XX-Small" />
</AddNewRowDefault>
</displaylayout>
</igtbl:UltraWebGrid>
Am I missing something? Do I have a setting improperly set? Or is this not possible with hierarchical grids?
I appreciate any assistance.
Mark
So I finally figured out what I had set incorrectly, in order to make the copy() function work. Below is what I originally had set:
<activationobject bordercolor="" borderwidth="0px" allowactivation="False" borderstyle="None"></activationobject>
Now, all I needed to do was remove the allowactivation="False" tag, and it is good to go:
<activationobject bordercolor="" borderwidth="0px" borderstyle="None"></activationobject>
Why Infragistics couldn't just tell me this is beyond my ability to understand. I had to figure this out from a working example they sent me and change sections one at a time in the WebGrid module until I found the setting that caused the copy() to fail.
I hope this helps others who have had the same issue.
Right, this is a good way to go. While we do try the best to help here (in peer to peer forums), sometimes it is better (especially in urgent cases) to contact our official dedicated support services, especially for tricky questions like security / clipobaord operations in various browsers.
Hopefully someone else will also be able to add something here (if he got that working correctly in this case)
I appreciate the suggestion above, with all the code, but this seams like a cludge instead of a solution. I think the real solution is for Infragistics to fix thier application so the copy function works.
I will open a trouble ticket with them to get this issue fixed.
Thanks for the suggestions, but they unfortunately didn't work. I still can't get the copy function to work in IE.
I think, especially for FireFox, clipboard operations are not something that the UltraWebGrid can control internally. FireFox is very strict when it comes to permissions and especially clipboard operations.
Still, there are some venues you can try. I think the following thread is especially useful:
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_21269346.html
[scroll down a lot after the Ads to see the response]
and especially the generic copy function here:
function copy_clip(maintext) { if (window.clipboardData) { // the IE-manier window.clipboardData.setData("Text", maintext); } else if (window.netscape) { netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); if (!clip) return; var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if (!trans) return; trans.addDataFlavor('text/unicode'); var str = new Object(); var len = new Object(); var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); var copytext=maintext; str.data=copytext; trans.setTransferData("text/unicode",str,copytext.length*2); var clipid=Components.interfaces.nsIClipboard; if (!clip) return false; clip.setData(trans,null,clipid.kGlobalClipboard); } alert("Following info was copied to your clipboard:\n\n" + maintext); return false; } //-->