Collapsible/expandable grouping using C# stored proc not working

Collapsible/expandable grouping using C# stored proc not working

srainsrain Posts: 11Questions: 4Answers: 0
edited July 2014 in Free community support

Please bear with me, I am new to Datatables.
I'm using returning Datatables from my stored proc in C#.
My data returns as

  • CUSTOMER COUNTSTATUS PRODUCT STATUS

  • +Customer A 2/3 Product A Sold

  • +Customer A 2/3 Product B Sold

  • +Customer A 2/3 Product C Pending

  • +Customer B 1/2 Product B Sold

  • +Customer B 1/2 Product D Pending

The results I am trying to achieve is this, with the indented shown after all expanded

COLLAPSED version

  • Customer A 2/3
  • Customer B 1/2

EXPANDED version

  • Customer A 2/3

  • ----- Product A Sold

  • ----- Product B Sold

  • ----- Product C Pending
  • Customer B 1/2

  • ----- Product B Sold

  • ----- Product D Pending

I have looked at this page https://jquery-datatables-row-grouping.googlecode.com/svn/trunk/collapsibleGroups.html and tried but it's not working

JScript I am using :

$(document).ready( function () {
$(document).ready( function () {
$('#example').dataTable({ "bLengthChange": false, "bPaginate": false})
.rowGrouping({bExpandableGrouping: true});
} );
}

HTML C# .aspx:

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th></th>
            <th>Customer</th>
            <th>CountStatus</th>
        </tr>
    </thead>
    <tbody>
         <asp:Literal runat="server" ID="ltData"></asp:Literal>
    </tbody>
</table>

C# code behind:

private void loadGrid()
{
StringBuilder sb = new StringBuilder();

    DataTable dt = new DataTable();
    string connstr = "Data Source=localhost;Initial Catalog=Datatable1;User ID=11;Password=xxx;Connection Timeout=20";
    using (SqlConnection conn = new SqlConnection(connstr))
    {
        SqlCommand sqlComm = new SqlCommand("reportStoredProc", conn);
        sqlComm.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = sqlComm;
        da.Fill(dt);
    }

    if (dt != null)
        if (dt.Rows.Count > 0)
            foreach (DataRow dr in dt.Rows)
            {
                sb.Append("<tr>");
                sb.Append("<td>");
                sb.Append("<data=null class='details-control' />");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append((dr["Customer"]));
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append((dr["CountStatus"]));
                sb.Append("</td>");
                sb.Append("</tr>");
            }

    ltData.Text = sb.ToString();

}
This discussion has been closed.