Hi,
I'm using a HyperLink column in a webGrid. Clicking the hyperLink opens a new window, but the new opened window does not get the focus.
I did it by:
CEIDCell.Column.Type = ColumnType.HyperLink;
CEIDCell.AllowEditing = AllowEditing.No;
How can I cause the new window get the focus?
Thanks
Maya
Intel
I am trying to reproduce this error, unfortunately to no avail. Is there something that I am missing? I am binding to standard NorthWind database and using your syntax in the grid InitializeRow event. I tested both in Firefox and IE and was able to get the new page open and gain office just fine.
Is it possible that there is something else that is interfering with the focus on the page (e.g. input controls, other control on the page, etc).
Here is my code:
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" DataSourceID="AccessDataSource1" Height="200px" oninitializerow="UltraWebGrid1_InitializeRow" Width="325px"> <bands> <igtbl:UltraGridBand> <Columns> <igtbl:UltraGridColumn BaseColumnName="ProductID" DataType="System.Int32" IsBound="True" Key="ProductID"> <Header Caption="ProductID"> </Header> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="ProductName" IsBound="True" Key="ProductName"> <Header Caption="ProductName"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="SupplierID" DataType="System.Int32" IsBound="True" Key="SupplierID"> <Header Caption="SupplierID"> <RowLayoutColumnInfo OriginX="2" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="2" /> </Footer> </igtbl:UltraGridColumn> </Columns> <addnewrow view="NotSet" visible="NotSet"> </addnewrow> </igtbl:UltraGridBand> </bands> <displaylayout bordercollapsedefault="Separate" name="UltraWebGrid1" rowheightdefault="20px" version="4.00"> <framestyle borderstyle="Solid" borderwidth="1px" font-names="Verdana" font-size="8pt" height="200px" width="325px"> </framestyle> <pager> <PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <borderdetails colorleft="White" colortop="White" /> </PagerStyle> </pager> <editcellstyledefault borderstyle="None" borderwidth="0px"> </editcellstyledefault> <headerstyledefault backcolor="LightGray" borderstyle="Solid"> <borderdetails colorleft="White" colortop="White" /> </headerstyledefault> <rowstyledefault backcolor="White" bordercolor="Gray" borderstyle="Solid" borderwidth="1px" font-names="Verdana" font-size="8pt"> <padding left="3px" /> <borderdetails colorleft="White" colortop="White" /> </rowstyledefault> <addnewbox> <boxstyle backcolor="LightGray" borderstyle="Solid" borderwidth="1px"> <borderdetails colorleft="White" colortop="White" /> </boxstyle> </addnewbox> <activationobject bordercolor="" borderwidth=""> </activationobject> </displaylayout> </igtbl:UltraWebGrid> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT [ProductID], [ProductName], [SupplierID] FROM [Alphabetical List of Products]"> </asp:AccessDataSource>protected void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { UltraGridCell CEIDCell = e.Row.Cells.FromKey("ProductID"); CEIDCell.Column.Type = ColumnType.HyperLink; CEIDCell.TargetURL = string.Format("@[_blank]default.aspx?ID={0}", CEIDCell.Value); CEIDCell.AllowEditing = AllowEditing.No; }
Thanks for your reply.
It works fine when I have only one bound webGrid. But when I have another bound webGrid on the same page then the new window opened from the first webGrid loses the focus. (if the second webGrid is not bound then its ok)
Please advice, I feel like I'm loosing my mind with that issue
Maya -
I know it's been several months since this post, but I wanted to know if you ever found a solution for this. I'm having the same issue. I thought it was specific to version 6.3, but apparently not...
Thanks,
Craig
What I believe that's happening here is likely a timing issue. WebGrid is likely trying to process some other activity, such as cell activation, as the other window is opening. The end result of this other activity is that the grid's window steals focus back from the child window. It's a simple race condition, and since the child window is being opened via navigation, there's nothing we can do to prevent the "race" from occurring.
The following thread details a way to prevent the grid from processing that other activity that seems to be stealing focus:http://news.infragistics.com/forums/p/813/10605.aspx
Thanks, Vince! Incidentally, I just came across that link about 2 hrs ago while searching the forums, and tried it out. The solution worked beautifully.
Sorry for the delay, but I was not connected for a month.
I'm happy we found a solution, I didn't find anything till now. could you please explain what you did (code sample will also be great)
Below is what I used. Just make sure you add both the MouseDownHandler and MouseUpHandler methods to the ClientSideEvents. Put the code below within the script tags (script language=javascript).
In the code below, oCell.Column represents the column containing the hyperlink. That's the reason for oCell.Column.Key.toLowerCase() == 'view' (I didn't want to set the _mouseDown property every time a user pressed down on the mouse).
Well, it worked great for me. Here is a link on the forum that goes into a little more detail:
http://news.infragistics.com/forums/p/813/10605.aspx
var m_fFirstTime = 1;
function dgFiles_MouseDownHandler(gridName, id, button){ if (m_fFirstTime == 1) { var oCell = igtbl_getCellById(id); if(oCell != null) { if (oCell.Column.Key.toLowerCase() == 'view') { m_fFirstTime = 0; oCell.Band.Grid._mouseDown = 0; } } }}function dgFiles_MouseUpHandler(gridName, id, button){ var oCell = igtbl_getCellById(id); if(oCell != null) { if (oCell.Column.Key.toLowerCase() == 'view') { return true; } }}
Hey HBA,
Thank you soooooooooo much...
i tried it and it works successfully.....
Naveen,
Thanks a lot for the solution.
Cheers.
Great solution! I'm going to try this on a new grid I need that must client sort. Thanks for posting this.
For my case I had the client side sorting enable and could not lose the mouse down event handler like HBA's post above.
I made some modifications to the javascript.
First you need to try catch the code so that when the header is clicked a javascript error is not thrown.
-----------------------------------------------------------
function grid_MouseDownHandler(gridName, id, button)
{
var oGrid = igtbl_getGridById(gridName);
var oCell = igtbl_getCellById(id); try { var cellName = oCell.Column.Key.toLowerCase(); switch(cellName) { case "hyperlinkcellname": return true; break; default: return false; } } catch(e) { return false; }
}
Set client side event handler as below.
<ClientSideEvents MouseDownHandler="grid_MouseDownHandler">
------------------------------------------------------------
This way I was able to skip the js code when the click is not from the hyper link column.
Hope this helps.
Naveen
In my world, sorting is off. But I'm wondering if it's possible on the client side to detect that a header was clicked, and if so do a sort?