将工具提示分配给 Infragistics WebDataGrid 中选定行的单元格
Assign Tooltip to cell of selected row in Infragistics WebDataGrid
我有一个组名的 Infragistics WebDataGrid。我想在组单元格中添加一个工具提示,在用户选择它时列出与该组关联的医生。
我创建了一个行选择事件,该事件在选择组行时获取医生的名字。方法如下, returns 选择行时的名称。当我将字符串分配给工具提示时,当您将鼠标悬停在单元格上时,工具提示不显示。
protected void wdgMedGrp_RowSelected(object sender, Infragistics.Web.UI.GridControls.SelectedRowEventArgs e)
{
Infragistics.Web.UI.GridControls.SelectedRowCollection selectedRows = e.CurrentSelectedRows;
int iMedicalGroupID = Convert.ToInt32(selectedRows[0].Items.FindItemByKey("ID").Value.ToString());
//Get Doctor names for this group
DataTable dtDoctors = new DataTable("Doctors");
SqlConnection SqlConn = null;
string strSqlConnection = ConfigurationManager.ConnectionStrings["CAP06"].ConnectionString;
using (SqlConn = new SqlConnection(strSqlConnection))
{
using (SqlCommand SqlCmd = new SqlCommand("phyadmGetPhysicianNames", SqlConn))
{
SqlCmd.CommandType = CommandType.StoredProcedure;
SqlCmd.Parameters.Add("@MedicalGroupID", SqlDbType.Int).Value = iMedicalGroupID;
SqlConn.Open();
using (SqlDataAdapter dataReturned = new SqlDataAdapter(SqlCmd))
{
dataReturned.Fill(dtDoctors);
}
}
}
string strPhysicianNames = string.Empty;
foreach(DataRow row in dtDoctors.Rows)
{
strPhysicianNames += row["PhysicianFullName"].ToString() + "\r\n";
}
selectedRows[0].Items.FindItemByKey("Name").Tooltip = strPhysicianNames;
}
这是我的标记:
<ig:WebHierarchicalDataGrid runat="server" height="600px" width="875px"
AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="ID"
DataMember="SqlDataSource3_DefaultView" StyleSetName="Windows7" ID="wdgMedGrp"
DataSourceID="WebHierarchicalDataSource2" Key="SqlDataSource3_DefaultView"
OnRowAdded="wdgMedGrp_RowAdded" OnRowSelectionChanged="wdgMedGrp_RowSelected">
<Columns>
<ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true">
<Header Text="ID" />
<header text="ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Name" Key="Name" Width="68%">
<Header Text="Name" />
<header text="Name" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="IsVisible" Key="IsVisible" Width="22%">
<Header Text="Is Visible?" />
<header text="Is Visible?" />
</ig:BoundDataField>
</Columns>
<Behaviors>
<ig:Filtering>
</ig:Filtering>
<ig:RowSelectors EnableInheritance="True" RowSelectorCssClass="groupRowSelectorWidth">
</ig:RowSelectors>
<ig:Selection RowSelectType="Single" Enabled="true" CellClickAction="Row">
<AutoPostBackFlags RowSelectionChanged="true" />
</ig:Selection>
</Behaviors>
为什么工具提示不显示?
谢谢。
我也有类似的需求。我通过创建另一个隐藏列来解决它,其中包含我想要的每一行的工具提示,然后在 InitializeRow 事件中设置工具提示,如下所示:
Protected void wdgMedGrp_InitializeRow(object sender, RowEventArgs e)
{
try
{
e.Row.Items[1].Tooltip = e.Row.Items[2].Value.ToString();
}
catch (Exception){} // ignore any exceptions
}
效果很好。缺点是我必须对每条记录都这样做,一次一条,这意味着我无法使用 SQL 调用中的 .Fill() 方法。
我有一个组名的 Infragistics WebDataGrid。我想在组单元格中添加一个工具提示,在用户选择它时列出与该组关联的医生。 我创建了一个行选择事件,该事件在选择组行时获取医生的名字。方法如下, returns 选择行时的名称。当我将字符串分配给工具提示时,当您将鼠标悬停在单元格上时,工具提示不显示。
protected void wdgMedGrp_RowSelected(object sender, Infragistics.Web.UI.GridControls.SelectedRowEventArgs e)
{
Infragistics.Web.UI.GridControls.SelectedRowCollection selectedRows = e.CurrentSelectedRows;
int iMedicalGroupID = Convert.ToInt32(selectedRows[0].Items.FindItemByKey("ID").Value.ToString());
//Get Doctor names for this group
DataTable dtDoctors = new DataTable("Doctors");
SqlConnection SqlConn = null;
string strSqlConnection = ConfigurationManager.ConnectionStrings["CAP06"].ConnectionString;
using (SqlConn = new SqlConnection(strSqlConnection))
{
using (SqlCommand SqlCmd = new SqlCommand("phyadmGetPhysicianNames", SqlConn))
{
SqlCmd.CommandType = CommandType.StoredProcedure;
SqlCmd.Parameters.Add("@MedicalGroupID", SqlDbType.Int).Value = iMedicalGroupID;
SqlConn.Open();
using (SqlDataAdapter dataReturned = new SqlDataAdapter(SqlCmd))
{
dataReturned.Fill(dtDoctors);
}
}
}
string strPhysicianNames = string.Empty;
foreach(DataRow row in dtDoctors.Rows)
{
strPhysicianNames += row["PhysicianFullName"].ToString() + "\r\n";
}
selectedRows[0].Items.FindItemByKey("Name").Tooltip = strPhysicianNames;
}
这是我的标记:
<ig:WebHierarchicalDataGrid runat="server" height="600px" width="875px"
AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="ID"
DataMember="SqlDataSource3_DefaultView" StyleSetName="Windows7" ID="wdgMedGrp"
DataSourceID="WebHierarchicalDataSource2" Key="SqlDataSource3_DefaultView"
OnRowAdded="wdgMedGrp_RowAdded" OnRowSelectionChanged="wdgMedGrp_RowSelected">
<Columns>
<ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true">
<Header Text="ID" />
<header text="ID" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Name" Key="Name" Width="68%">
<Header Text="Name" />
<header text="Name" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="IsVisible" Key="IsVisible" Width="22%">
<Header Text="Is Visible?" />
<header text="Is Visible?" />
</ig:BoundDataField>
</Columns>
<Behaviors>
<ig:Filtering>
</ig:Filtering>
<ig:RowSelectors EnableInheritance="True" RowSelectorCssClass="groupRowSelectorWidth">
</ig:RowSelectors>
<ig:Selection RowSelectType="Single" Enabled="true" CellClickAction="Row">
<AutoPostBackFlags RowSelectionChanged="true" />
</ig:Selection>
</Behaviors>
为什么工具提示不显示?
谢谢。
我也有类似的需求。我通过创建另一个隐藏列来解决它,其中包含我想要的每一行的工具提示,然后在 InitializeRow 事件中设置工具提示,如下所示:
Protected void wdgMedGrp_InitializeRow(object sender, RowEventArgs e)
{
try
{
e.Row.Items[1].Tooltip = e.Row.Items[2].Value.ToString();
}
catch (Exception){} // ignore any exceptions
}
效果很好。缺点是我必须对每条记录都这样做,一次一条,这意味着我无法使用 SQL 调用中的 .Fill() 方法。