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
I'm trying to implement that solution, but I'm using ultraWebGrid and I could not find any mouse event or property on it.
Please advice
Maya,
This isn't in the code behind, it's client side java script. Go to the properties of the grid. Open DisplayLayout, then ClientSideEvents. You'll see the two events there. In the drop-down, select "Add new handler" and it will create the blank java script place holder for you. Then you can paste in the code above.
Thanks, I tried it but I guess I missed something...
First of all - the problem occurs only when I have 2 webGrids on the same page. When its only one then everything is ok. So do I need to implement these 2 methods for both of the Grids or only for the one which contains the link?
And, Could you please explain the meaning of the return value of MouseDownHandler and MouseUpHandler? I'm asking it in order to understand what to write in the method body.
Hi Maya,
Try adding this code for MouseDown client side event for the grid which contains link.
function grid_MouseDownHandler(gridName, id, button)
{
var grid = igtbl_getGridById(gridName);
grid.Element.removeAttribute("mouseDown");
}
Set client side event handler as below.
<ClientSideEvents MouseDownHandler="grid_MouseDownHandler"
Let me know if this works for you.
Greetings
This would be trouble if you have client side sorting enabled
It would remove the mouse click handler that enables sorting on the grid.
I am trying to find a solution for this but will check the other two links mentioned in the thread.
Naveen
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.
-----------------------------------------------------------
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; }
<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.
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?