Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
WebHierarchicalDataGrid LINQ Object Binding
posted

 This is my first time using the Web Hierarchical Data Grid as I’m prototyping a sample given a use case on my new project to decide if Infragistics’ bits and pieces can achieve our design goals. I’ve used the ultra web grid on past projects and we would use two dimensional binding using LINQ to flatten an object graph and then bind to the IEnumerable<Anonymous> list. My past experience leads to my attempted solution. I want to search for a client, then using the hierarchical capability, expand the grid to show the clients case files, to then choose it for review. My thinking is the object graph is too complex for a straight bind (see attached pic), so I used a LINQ query to produce what I think is more a manageable graph.
LINQ Query code:
 
protected void Button1_Click(object sender, EventArgs e)
        {
            ClientSearchCriteria criteria = new ClientSearchCriteria {LastName = TextBox1.Text};
 
            IClientManager clientManager = IoC.Resolve<IClientManager>();
            IList<Client> clients = clientManager.GetClientList(criteria);
 
            var bindList = from c in clients
                           orderby c.Person.LastName, c.Person.FirstName
                           select new { c.Id, c.Person.LastName, c.Person.FirstName, c.Person.HealthCardNumber, c.Person.DOB, c.ClientCases };
 
            whdg1.DataSource = bindList;
            whdg1.DataBind();
        }
Markup:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <coo:TextBox ID="TextBox1" runat="server"></coo:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    <ig:WebHierarchicalDataGrid ID="whdg1" runat="server"
            AutoGenerateColumns="false" AutoGenerateBands="false" InitialExpandDepth="0" DataKeyFields="Id"
            InitialDataBindDepth="0" Height="380px" Width="700px">          
            <Columns>
                <ig:BoundDataField DataFieldName="LastName" Key="LastName" Header-Text="Last Name" />
                <ig:BoundDataField DataFieldName="FirstName" Key="FirstName" Header-Text="First Name" Width="230px" />
                <ig:BoundDataField DataFieldName="HealthCardNumber" Key="HealthCardNumber" Header-Text="OHIP" Width="150px" />
                <ig:BoundDataField DataFieldName="DOB" Key="DOB" Header-Text="DOB"                    Width="80px" />
            </Columns>
        </ig:WebHierarchicalDataGrid>
</asp:Content>
 
In the LINQ query, Id = GUID, LastName=string, FirstName=string, HealthCardNumber=string, DOB=DateTime, ClientCases=IList<ClientCase>
 
I want the child band to bind to the IList<ClientCase> is this possible? What if I want to bind to CaseFileId, and subject only? How do I do accomplish my goal?
Thanks in advance,
 
Adam Brunk