Infragistics WebHierarchicalDataGrid无法确定何时选择子行,然后确定如何获取所选数据

时间:2013-05-08 04:40:32

标签: asp.net c#-4.0 infragistics webgrid

我已将WebHierarchicalDataGrid拖到页面上并告诉它不要自动生成波段或自动生成列。启用Ajax未选中。通过代码隐藏,我手动为父表和子表创建了网格上的列。我双击RowSelectionEvent来测试事件是否会触发。当我从子表中选择一行时,事件永远不会触发。是否有我不知道的子行选择事件?如果没有,有人可以告诉我从所选子行获取字段数据的正确方法。我已经在这方面工作了好几天,我很沮丧,似乎没有简单的方法来完成这项任务。任何帮助是极大的赞赏。

这是我的代码:

protected void WebHierarchicalDataGrid1_Init(object sender,EventArgs e)         {             string physicianNPI;             physicianNPI = Session.Contents [“physicianNPI”]。ToString();

        // Create Parent Row - Patient Table 
        WebHierarchicalDataGrid1.DataSource = WebHierarchicalDataSource1;
        WebHierarchicalDataGrid1.DataKeyFields = "MPI";
        WebHierarchicalDataGrid1.Columns.Add(CreateNewBoundDataField("MPI", "MPI"));
        WebHierarchicalDataGrid1.Columns.Add(CreateNewBoundDataField("Fname", "Fname"));
        WebHierarchicalDataGrid1.Columns.Add(CreateNewBoundDataField("Lname", "Lname"));
        WebHierarchicalDataGrid1.Columns.Add(CreateNewBoundDataField("DOB", "DOB"));
        WebHierarchicalDataGrid1.Columns.Add(CreateNewBoundDataField("Address", "Address"));
        WebHierarchicalDataGrid1.Columns.Add(CreateNewBoundDataField("SSN", "SSN"));

        // Create Child Rows - Referral Table
        WebHierarchicalDataGrid1.Bands.Add(CreateNewBand("LinqDataSource1Referrals_DefaultView", "LinqDataSource1Referrals_DefaultView", "REFGUID"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1Referrals_DefaultView"].Columns.Add(CreateNewBoundDataField("MPI", "MPI"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1Referrals_DefaultView"].Columns.Add(CreateNewBoundDataField("RefDate", "Refferal Date"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1Referrals_DefaultView"].Columns.Add(CreateNewBoundDataField("RefReason", "Referral Reason"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1Referrals_DefaultView"].Columns.Add(CreateNewBoundDataField("Insurance", "Insurance"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1Referrals_DefaultView"].Columns.Add(CreateNewBoundDataField("AcceptDate", "Accept Date"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1Referrals_DefaultView"].Columns.Add(CreateNewBoundDataField("DenyDate", "Deny Date"));

        // Create Child Rows - UpLoad Table
        WebHierarchicalDataGrid1.Bands.Add(CreateNewBand("LinqDataSource1UpLoad_DefaultView", "LinqDataSource1UpLoad_DefaultView", "UploadIndex"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1UpLoad_DefaultView"].Columns.Add(CreateNewBoundDataField("MPI", "MPI"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1UpLoad_DefaultView"].Columns.Add(CreateNewBoundDataField("FileDate", "File Date"));
        WebHierarchicalDataGrid1.Bands["LinqDataSource1UpLoad_DefaultView"].Columns.Add(CreateNewBoundDataField("FileType", "File Type"));



        this.WebHierarchicalDataGrid1.Columns[0].Hidden = true;
        WebHierarchicalDataGrid1.Bands[0].Columns[0].Hidden = true;
        WebHierarchicalDataGrid1.Bands[1].Columns[0].Hidden = true;



    }



    public static BoundDataField CreateNewBoundDataField(string columnName, string headerText)
    {
        BoundDataField boundDataField = new BoundDataField();
        boundDataField.DataFieldName = columnName;
        boundDataField.Key = columnName;
        boundDataField.Header.Text = headerText;

        return boundDataField;
    }

    public static Band CreateNewBand(string key, string dataMember, string dataKeyField)
    {
        Band band = new Band();
        band.AutoGenerateColumns = false;
        band.Key = key;
        band.DataMember = dataMember;
        band.DataKeyFields = dataKeyField;
        return band;
    }

    protected void WebHierarchicalDataGrid1_InitializeBand(object sender, BandEventArgs e)
    {
        foreach (var item in e.Band.Columns)
        {

            if (item is BoundDataField)
            {
                BoundDataField field = item as BoundDataField;
                string fieldname;
                fieldname = field.ToString();


        // Set the column width for each field displayed in a grid.


                if (fieldname.Contains("Fname"))
                {
                    field.Width = Unit.Parse("75");
                }

                if (fieldname.Contains("Lname"))
                {
                    field.Width = Unit.Parse("75");
                }

                if (fieldname.Contains("Address"))
                {
                    field.Width = Unit.Parse("190");
                }

                if (fieldname.Contains("DOB"))
                {
                    field.Width = Unit.Parse("75");
                }

                if (fieldname.Contains("SSN"))
                {
                    field.Width = Unit.Parse("75");
                }

                if (fieldname.Contains("FileDate"))
                {
                    field.Width = Unit.Parse("75");
                }
                if (fieldname.Contains("FileType"))
                {
                    field.Width = Unit.Parse("100");
                }


            }
        }

取得一些进展。当我选择第二个子行时,行选择事件现在正在触发。我在WebHierarchicalDataGrid上更改了以下属性。

WebHierarchicalDataGrid1属性 - >选择 - > AutoPostBackFlags - > RowSelectionChanged - >真(原本是假的)

我也做了这些改变。不确定他们是否有所作为。

属性 - > RowSelectorClientEvents - > RowSelectorClicked - > WebHierarchicalDataGrid1_Selection_RowSelectionChanged

属性 - > RowSelectorClientEvents-> RowSelectorClicking - > WebHierarchicalDataGrid1_Selection_RowSelectionChanged

这是GRID ASP.net代码:           

        <ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" AutoGenerateBands="False" AutoGenerateColumns="False" EnableAjax="False" Height="350px" style="z-index: 1; left: 0px; top: 30px; position: absolute; height: 352px; width: 402px" Width="875px" OnInit="WebHierarchicalDataGrid1_Init" OnInitializeBand="WebHierarchicalDataGrid1_InitializeBand" OnRowSelectionChanged="WebHierarchicalDataGrid1_RowSelectionChanged" OnRowIslandDataBound="WebHierarchicalDataGrid1_RowIslandDataBound" >
            <Behaviors>
                <ig:Selection RowSelectType="Single">
                    <SelectionClientEvents RowSelectionChanged="WebHierarchicalDataGrid1_Selection_RowSelectionChanged" />
                    <AutoPostBackFlags RowSelectionChanged="True" />
                </ig:Selection>
                <ig:RowSelectors EnableInheritance="True">
                    <RowSelectorClientEvents RowSelectorClicked="WebHierarchicalDataGrid1_Selection_RowSelectionChanged" RowSelectorClicking="WebHierarchicalDataGrid1_Selection_RowSelectionChanged" />
                </ig:RowSelectors>
            </Behaviors>
        </ig:WebHierarchicalDataGrid>
        <igtxt:WebImageButton ID="btnViewChartData" runat="server" OnClick="btnViewChartData_Click" style="z-index: 1; left: 417px; top: 438px; position: absolute" Text="View Chart Data" UseBrowserDefaults="False">
            <Appearance>
                <ButtonStyle BackColor="Control" BorderStyle="Solid" BorderWidth="1px" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False">
                    <BorderDetails ColorBottom="112, 112, 112" ColorLeft="240, 240, 240" ColorRight="112, 112, 112" ColorTop="240, 240, 240" />
                </ButtonStyle>
                <InnerBorder ColorBottom="160, 160, 160" ColorLeft="White" ColorRight="160, 160, 160" ColorTop="White" StyleBottom="Solid" StyleLeft="Solid" StyleRight="Solid" StyleTop="Solid" WidthBottom="1px" WidthLeft="1px" WidthRight="1px" WidthTop="1px" />
            </Appearance>
            <FocusAppearance>
                <ButtonStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False">
                    <BorderDetails ColorBottom="Black" ColorLeft="Black" ColorRight="Black" ColorTop="Black" />
                </ButtonStyle>
                <InnerBorder ColorBottom="224, 224, 224" ColorLeft="246, 246, 246" ColorRight="224, 224, 224" ColorTop="246, 246, 246" StyleBottom="Ridge" StyleLeft="Solid" StyleRight="Ridge" StyleTop="Solid" WidthBottom="2px" WidthLeft="2px" WidthRight="2px" WidthTop="2px" />
            </FocusAppearance>
            <HoverAppearance>
                <ButtonStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False">
                </ButtonStyle>
            </HoverAppearance>
            <PressedAppearance>
                <ButtonStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False">
                    <BorderDetails ColorBottom="Black" ColorLeft="Black" ColorRight="Black" ColorTop="Black" />
                </ButtonStyle>
                <InnerBorder ColorBottom="246, 246, 246" ColorLeft="112, 112, 112" ColorRight="246, 246, 246" ColorTop="112, 112, 112" StyleBottom="Solid" StyleLeft="Solid" StyleRight="Solid" StyleTop="Solid" WidthBottom="2px" WidthLeft="2px" WidthRight="2px" WidthTop="2px" />
            </PressedAppearance>
            <DisabledAppearance>
                <ButtonStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False">
                </ButtonStyle>
            </DisabledAppearance>
        </igtxt:WebImageButton>
    </Template>
</igmisc:WebGroupBox>
<ig:WebScriptManager ID="WebScriptManager1" runat="server">
</ig:WebScriptManager>
 <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Californian FB" ForeColor="Blue" style="z-index: 1; left: 676px; top: 25px; position: absolute" Text="Referral Inbox"></asp:Label>
<ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server" style="z-index: 1; left: 0px; top: -2px; position: absolute; height: 38px; width: 413px">
    <DataViews>
        <ig:DataView ID="LinqDataSource1Patients_DefaultView" DataMember="DefaultView" DataSourceID="LinqDataSource1Patients" />
        <ig:DataView ID="LinqDataSource1UpLoad_DefaultView" DataMember="DefaultView" DataSourceID="LinqDataSource1UpLoad" />
        <ig:DataView ID="LinqDataSource1Referrals_DefaultView" DataMember="DefaultView" DataSourceID="LinqDataSource1Referrals" />
    </DataViews>
    <DataRelations>
        <ig:DataRelation ChildColumns="MPI" ChildDataViewID="LinqDataSource1UpLoad_DefaultView" ParentColumns="MPI" ParentDataViewID="LinqDataSource1Patients_DefaultView" />
        <ig:DataRelation ChildColumns="MPI" ChildDataViewID="LinqDataSource1Referrals_DefaultView" ParentColumns="MPI" ParentDataViewID="LinqDataSource1Patients_DefaultView" />
    </DataRelations>
</ig:WebHierarchicalDataSource>
<asp:LinqDataSource ID="LinqDataSource1UpLoad" runat="server" ContextTypeName="PilotProjectV1._01.PilotProjectDBDataContext" EntityTypeName="" TableName="UpLoads">
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDataSource1Referrals" runat="server" ContextTypeName="PilotProjectV1._01.PilotProjectDBDataContext" EntityTypeName="" TableName="Referrals" Where="SendingPhysicianNPI == @SendingPhysicianNPI">
    <WhereParameters>
        <asp:SessionParameter Name="SendingPhysicianNPI" SessionField="physicianNPI" Type="Decimal" />
    </WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="LinqDataSource1Patients" runat="server" ContextTypeName="PilotProjectV1._01.PilotProjectDBDataContext" EntityTypeName="" TableName="Patients">
</asp:LinqDataSource>

1 个答案:

答案 0 :(得分:3)

尝试将您的行为部分更改为

<Behaviors>
   <ig:Selection RowSelectType="Single" CellClickAction="Row" CellSelectType="None">
      <AutoPostBackFlags RowSelectionChanged="True" />
   </ig:Selection>
</Behaviors>

只需确保在任何点击行选择被触发