Closed d42ohpaz closed 4 years ago
@9ae8sdf76 , @mpryvkin
Hello there.
I made some bug fixes and some improvements including some of this request.
Source: here.
I supposed that if rowId
is provided, it should be used. If not, is used cell.data()
.
I didn't used internal row number because that it could be changed using RowReorder
or by adding new rows... and is a lot of extra work that could be avoided using a rowId
.
Thank you for the efforts!
@nikitul do you want to create the PR, or should I?
@9ae8sdf76 Any time. Please send me (or here) some feedback. I don't know what's a PR (I am newbie with Github) so... do it :)
@nikitul no worries; we all start somewhere. Feel free to read up on the Standard Fork and Pull Request Workflow to get more familiar with the process.
@9ae8sdf76 Thank you.
I am not sure I understand the problem.
If you want to use row ID provided by DT_RowId
or another data property for the checkbox column, just use 'data': 'DT_RowId'
option for your column definition. For example:
'columnDefs': [
{
'targets': 0,
'checkboxes': true,
'data': 'DT_RowId'
}
],
This doesn't require any code changes as suggested by the pull request #114.
There are cases where checkbox can be used in multiple columns. I would rather not blindly revert to use row ID if cell data is missing and would prefer to either:
Regarding quoted limitation of the script to require unique data, I am planning to remove this limitation in future by allowing column with checkboxes to not have any data, if all is needed is the state of the checkbox.
Sorry for this (very) late response. 2020 was very busy one...
Those changes I suggested in this pull request were because in some cases it is needed to get the whole data of the checked rows. And if DataTable settings are "serverSide": true
, all the current page checked rows data is gone when the page is changed and all we can get is the checked ID's. That is why I suggested also to create columns().checkboxes.ids()
for returning checked id's and columns().checkboxes.data()
functions for returning checked row's data .
Your 'data': 'DT_RowId'
suggestion does not solve this problem id I want checked DT_RowId
and cell.data()
and row.data()
on the same DataTable instance. It only allows to get row ID's or cell's data.
My goal was to:
allow me to get the checked row's ID's (based on DataTable dt.settings()[0].rowId
which it's implicit value is 'DT_RowId'
) - columns().checkboxes.ids()
allow me to get the checked cells value (for multiple columns, which could include - or not - rows ID's values) - columns().checkboxes.selected()
allow me to get the checked row's data in case of using DataTable settings "serverSide": true
- columns().checkboxes.data()
That is why I made that amount of changes.
There is a bug thought (in my version of code)... When Ajax is used to supply the data and "serverSide": false
and checked columns settings are 'checkboxes': {selectRow': false}
, if I check the selectAll
checkbox, only the visualized rows (pages) are selected (because not all rows are created in DOM).
I will try to update my version with your last changes and remove that bug.
Best Regards
THANK YOU!
Your "1.2.13-dev" version solved all my big problems!
Now it works sooooo nice with fixed columns (except dt.fixedColumns().cellIndex()
), and when I use DataTable settings"serverSide": true
, I capture the selected cell with 'selectCallback': function(cellNodes, isSelected){}
. I don't know why I don't used this function before.
There is a little problem with dt.fixedColumns().cellIndex()
. That piece of code should be replaced because is deprecated.
See [here](https://datatables.net/reference/api/fixedColumns().cellIndex()).
I will create another Issue for that, describing it.
Thanks Again!
Looking at the Known Limitations, it states:
I would like to request that absent a value in
columns.data()
, then fallback to therowId
. IfrowId
is not available, then use the internal row number that is provided by datatables.Thank you!