Search code examples
asp.netc#-4.0infragisticswebgrid

Infragistics WebHierarchicalDataGrid Unable to determine when a child row is selected and then how to get the data that is selected


I have dragged a WebHierarchicalDataGrid to the page and have told it not to autogenerate bands or autogenerate columns. Enable Ajax is unchecked. Via codebehind, I manually created the columns on the grid for both the parent and child tables. I have double clicked on RowSelectionEvent to test to see if the event ever fires. When I select a row from a child table, the event never fires. Is there a child row selection event that I am not aware of? If not can someone show me the correct way to get field data from a child row that was selected. I have been working on this for several days and I am pretty frustrated that there seems to be no easy way to accomplish this task. Any help is GREATLY appreciated.

Here is my code:

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");
                }


            }
        }

Making some progress. The row selection event is now firing when I select the second child row. I changed the following properties on the WebHierarchicalDataGrid.

WebHierarchicalDataGrid1 Properties -> Selection -> AutoPostBackFlags -> RowSelectionChanged -> True (it was originally false)

I also made these changes. Not sure if they made the difference though.

Properties -> RowSelectorClientEvents -> RowSelectorClicked -> WebHierarchicalDataGrid1_Selection_RowSelectionChanged

Properties -> RowSelectorClientEvents-> RowSelectorClicking -> WebHierarchicalDataGrid1_Selection_RowSelectionChanged

Here is the GRID ASP.net Code:

        <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>

Solution

  • Try changing your behavior section to

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

    Just ensuring that on any click Row selection is fired