Is there a way to change aiDisplay so that I can hide certain rows?

Is there a way to change aiDisplay so that I can hide certain rows?

vrgaonkarvrgaonkar Posts: 2Questions: 1Answers: 0
edited December 2014 in Free community support

Thank you for this wonderful plugin. In my code, I implement row grouping similar to http://www.datatables.net/examples/advanced_init/row_grouping.html I also allow the groups to be collapsed/expanded. When a group is collapsed, all the rows that belong to that group are hidden from view and when the group is expanded, the hidden rows can be seen again. All that works well.

My problem is that I am not able to remove these hidden rows from the aiDisplay array. I am trying to do this so that the hidden rows wont be counted amongst "visible" rows by the api which would mean the page numbers would automatically reduce the number of pages.

I tried setting aiDisplay to row indices which I want to be visible and then called draw(). After the draw however, aiDisplay had all the values that it had before i manually set it.

I saw in the datatables source code, after filtering, _fnCallbackFire() is called. I don't know if I should call this function instead of draw. I couldn't call it because I couldn't get a handle on this function.

Thank you.

Answers

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin

    Basically no, I'm afraid there isn't. DataTables doesn't implement an expand / collapse option for rows at the moment. I plan to create a row grouping in future, but that is likely a while off as there are other more pressing features that need to be added first.

    Sorry I don't have better news.

    Allan

  • vrgaonkarvrgaonkar Posts: 2Questions: 1Answers: 0

    Hey Allan, thank you for getting back to me. I managed to remove the unwanted indices from aiDisplay by tricking the datatable into thinking a search was fired (setting bFiltered - true) and splicing the unwanted indices from aiDisplay.

    However, as expected, this approach messed up the search functionality. I feel if I could do this in another event or maybe define a custom event of my own, I would be able to make the grouping work as I want it to.

    Can you suggest another event that I could use to achieve this? Is there a way to define a custom event of my own?

    Thanks.

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin

    You can define any event you want - but if you want it to be triggered in DataTables you would of course need to modify the base code (which you are free to do - it is open source!).

    Allan

This discussion has been closed.