Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Filter/Sort with hidden child rows #40

Open
etombaugh opened this issue May 2, 2019 · 3 comments
Open

Using Filter/Sort with hidden child rows #40

etombaugh opened this issue May 2, 2019 · 3 comments
Labels

Comments

@etombaugh
Copy link

etombaugh commented May 2, 2019

I have made a pretty complex table, and in the interest of showing important items without making the page overwhelming, I've made child rows in the table with the additional breakout of information. Then the user can click on the table row itself, the child row will expand and the details revealed using Bootstrap Accordion.

When I do this though, I get an error saying "Cannot read property 'innerHTML' of undefined", but removing the child rows make everything work again.

I only want the filtering to work on the parent rows, and leave the child rows alone. I would imagine that since the child row does not have the same structure as the parent row (essentially tables within the <tr>), it is not able to generate the filtering correctly.

Any suggestions? Perhaps a method to tell datatable to only filter/sort on the parent rows?

@Holt59
Copy link
Owner

Holt59 commented May 3, 2019

Could you show me a bit of the table layout? And also the line where the error occurs (if you are not using the minified version)?

You can specify a function in place of a filter, e.g.:

{
    filters: [
        function(data, text) { // First column
            return data == text; 
        }
    ]
}

@Holt59 Holt59 added the question label May 3, 2019
@etombaugh
Copy link
Author

Here is the error I am getting:

Uncaught TypeError: Cannot read property 'innerHTML' of undefined
    at new DataTable (datatable.js:135)
    at HTMLTableElement.<anonymous> (datatable.jquery.js:42)
    at Function.each (jquery.min.js:2)
    at w.fn.init.each (jquery.min.js:2)
    at w.fn.init.$.fn.datatable (datatable.jquery.js:21)
    at HTMLDocument.<anonymous> (view_all_rates:87014)
    at l (jquery.min.js:2)
    at c (jquery.min.js:2)

Table for example purposes (simplified). First row is the parent row, the second tag is for the hidden detail row.

<tr data-toggle="collapse" data-target="#rate_detail-1" class="accordion-toggle">
		<td rowspan="1" colspan="1">Test Data</td>
    <td rowspan="1" colspan="1">Test Data</td>
    <td rowspan="1" colspan="1">Test Data</td>

</tr>



<div id="rate_detail-1">
  <tr class="accordian-body collapse">
    <td colspan="10">
      <div class="col-md-6">
        <div class="box box-danger">
          <div class="box-header with-border">
            <h4 class="box-title">Rate Details</h4>
          </div>
          <div class="box-body">
            <table class="table table-bordered table-hover">
              <tbody>
                <tr>
                  <td>Carrier</td><td>Sample</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>

      </div>
    </td>
  </tr>
</div>

@Holt59
Copy link
Owner

Holt59 commented May 3, 2019

I do not really understand your example... You have two different rows each time? And you have one <tr> within a <div>? I am not sure this is valid HTML...

If you really have two different rows, it'll be quite complicated to do what you want... To use datatable at all actually since your two rows will probably get messed up when sorting / etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants