You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have 2 improvement suggestions concerning the selectRow property:
From a semantic point of view, I think it would be more appropriate for selectRow.mode to receive "single" and "multiple" rather than "radio" and "checkbox".
Indeed, it has a UI connotation (the way you want it to render) rather than a behavior connotation (the way you want it to behave). When specifying the mode I intend to tell the grid whether it supports single or multiple selection, which is the goal of the mode property. The fact that in the bottom line it renders a radio button or a checkbox is an implementation decision.
It makes even more sense when you use hideSelectColumn: true, since you don't care about the rendering, but you do care that selection is single or multiple rows.
Do you agree?
By the way your own constant names are inline with the way I think, i.e. Const.ROW_SELECT_SINGLE is radio and Const.ROW_SELECT_MULTI is checkbox. As a user of your package I cannot use your constant values and therfore I have to write radio and checkbox.
The _isSelectRowDefined function of TableBody.js checks whether the grid support selection by testing whether the mode property is one of the 2 values Const.ROW_SELECT_SINGLE or Const.ROW_SELECT_MULTI. In my point of view the right code should be: return (this.props.selectRow != undefined) which is enough for establishing whether grid supports selection or not.
Maybe you had a good reason for checking for the mode in this location, if yes I would be glad you give me your reason.
If the reason was to check that the mode provided was a legal value, then a better place to do it would be in BootstrapTable.propTypes or in TableBody.propTypes object definition.
Instead of: selectRow: React.PropTypes.shape({ mode: React.PropTypes.string, ... }),
Write: selectRow: React.PropTypes.shape({ mode: React.PropTypes.oneOf([Const.ROW_SELECT_SINGLE, Const.ROW_SELECT_MULTI]), ... }),
Thank you
The text was updated successfully, but these errors were encountered:
@dana2208,
I agree this both suggestion, but I'll improve second suggestion first, because first suggestion will cause user to change their client code, so I prefer not to fix first suggestion currently, how do you think
btw, this component have a lot of improvement need to do, its all keep in my mind, like make es6 more compatible, testing, refactoring src/TableBody.js, performance tuning etc.
@dana2208, btw for the second issue, I can't modify _isSelectRowDefined in src/TableBody.js for changing to return (this.props.selectRow != undefined); Because selectRow is always defined on BootstrapTable defaultProps.
Hi!
I have 2 improvement suggestions concerning the selectRow property:
selectRow.mode
to receive"single"
and"multiple"
rather than"radio"
and"checkbox"
.Indeed, it has a UI connotation (the way you want it to render) rather than a behavior connotation (the way you want it to behave). When specifying the mode I intend to tell the grid whether it supports single or multiple selection, which is the goal of the mode property. The fact that in the bottom line it renders a radio button or a checkbox is an implementation decision.
It makes even more sense when you use
hideSelectColumn: true
, since you don't care about the rendering, but you do care that selection is single or multiple rows.Do you agree?
By the way your own constant names are inline with the way I think, i.e.
Const.ROW_SELECT_SINGLE
isradio
andConst.ROW_SELECT_MULTI
ischeckbox
. As a user of your package I cannot use your constant values and therfore I have to writeradio
andcheckbox
._isSelectRowDefined
function ofTableBody.js
checks whether the grid support selection by testing whether themode
property is one of the 2 valuesConst.ROW_SELECT_SINGLE
orConst.ROW_SELECT_MULTI
. In my point of view the right code should be:return (this.props.selectRow != undefined)
which is enough for establishing whether grid supports selection or not.Maybe you had a good reason for checking for the mode in this location, if yes I would be glad you give me your reason.
If the reason was to check that the mode provided was a legal value, then a better place to do it would be in
BootstrapTable.propTypes
or inTableBody.propTypes
object definition.Instead of:
selectRow: React.PropTypes.shape({
mode: React.PropTypes.string,
...
}),
Write:
selectRow: React.PropTypes.shape({
mode: React.PropTypes.oneOf([Const.ROW_SELECT_SINGLE, Const.ROW_SELECT_MULTI]),
...
}),
Thank you
The text was updated successfully, but these errors were encountered: