簡體   English   中英

將工具提示分配給Infragistics WebDataGrid中所選行的單元格

[英]Assign Tooltip to cell of selected row in Infragistics WebDataGrid

我有一個組名稱的Infragistics WebDataGrid。 我想在組單元格中添加一個工具提示,以在用戶選擇該組時列出與此組關聯的醫生。 我創建了一個行選擇事件,該事件在選擇組行時獲取醫生的姓名。 該方法在下面,並在選擇該行時返回名稱。 當我將字符串分配給工具提示時,將鼠標懸停在單元格上時,工具提示不會顯示。

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()方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM