react-bootstrap-table icon indicating copy to clipboard operation
react-bootstrap-table copied to clipboard

DropUp instead of dropdown in Pagination

Open guntherlaurijssens opened this issue 9 years ago • 17 comments

When the pagination toolbar is at the bottom of the screen, the 'sizePerPageList' dropdown is hidden from the viewport.

You can override the styling for the dropdown yourself:

.react-bs-table-pagination .dropdown .dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-bottom: 2px;
}

Would it be possible to make the css class of the dropdown configurable, either dropdown or dropup?

guntherlaurijssens avatar Mar 10 '17 08:03 guntherlaurijssens

you can customize it, check https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/pagination/custom-size-per-page.js#L39

please upgrade to v3.0.0 to have the customization for all of the table.

let me know if you got any questions, thanks

AllenFang avatar Mar 11 '17 15:03 AllenFang

Hi @AllenFang , there are some problems about the pagination button in my program. From your documentation, I followed your examples. The page looks good, however it does't pop up options when I clicked on it, even the process did go in to the onToggleDropDown method.

and my code is:

import { BootstrapTable, TableHeaderColumn, SizePerPageDropDown} from 'react-bootstrap-table';
...
onToggleDropDown = (toggleDropDown) => {
       console.log('toggle dropdown');
       toggleDropDown();
   }

   renderSizePerPageDropDown = (props) => {
       return (
           <SizePerPageDropDown
               className = 'my-size-per-page'
               btnContextual='btn-warning'
               variation='dropup'
               onClick={() => this.onToggleDropDown(props.toggleDropDown)}
           />
       )
   }

  
   options = {
       // paginationPosition:"top",
       paginationShowsTotal: this.renderPaginationShowsTotal,
       sizePerPageList: [10,  30, 50, 60],
       sizePerPage: 10,
       sizePerPageDropDown: this.renderSizePerPageDropDown,
       exportCSVBtn: this.createCustomExportCSVButton,
      
   }


...
render() {
       return (
               <BootstrapTable data={this.state.dataArr} striped hover search 
               exportCSV condensed pagination options={this.options}>
               .........
               </BootstrapTable>
)}

On the browser side, I can see there are some styling changing in the new pagination button:

pag1

and I can click in the onToggleDropDown method:

pag2

The versions of those libs are:

react: '15.3.0'
react-dom : '15.2.1
react-bootstrap-table: '3.3.0',
react-bootstrap: '0.31.0',
bootstrap: '3.3.7'

Any advises about it? Thank you so much.

XidongHuang avatar May 08 '17 17:05 XidongHuang

I think you have to pass the other props as parameters to <SizePerPageDropDown ... />, i.e.

     return (
          <SizePerPageDropDown
              variation='dropup'
              {...props}
          />
      );

stephanebarbey avatar May 09 '17 15:05 stephanebarbey

@XidongHuang, I can not reproduce it, how about remove the bootstrap or react-bootstrap dependency and try again?

Also, thanks @stephanebarbey's answer, but I think we dont need to pass the props for this case :)

AllenFang avatar May 09 '17 16:05 AllenFang

hmmm. this was my workaround for @XidongHuang 's problem... (I had the same.) If I don't pass the props, when calling renderSizePerPageDropDown(...), the property open:true is not given to <SizePerPageDropDown ...>, which interprets that the dropdown is to remain closed, thus

The page looks good, however it does't pop up options when I clicked on it, even the process did go in to the onToggleDropDown method

but this is on my machine...

stephanebarbey avatar May 09 '17 16:05 stephanebarbey

Thanks @stephanebarbey and @AllenFang !

The way @stephanebarbey said above works, it does't need remove bootstrap or react-bootstrap, but need to add {...props} in the button <SizePerPageDropDown ... />.

I guess this problem is still about some changes in new react versions.

Anyway, thanks you both again!

XidongHuang avatar May 09 '17 17:05 XidongHuang

Really? it's kind of wired I think. what's the react version you guys use?

AllenFang avatar May 10 '17 12:05 AllenFang

@AllenFang The latest one 15.5.4 will throw an Error

ERROR in ./~/react-modal/~/react-dom/index.js
Module not found: Error: Can't resolve 'react/lib/ReactDOM'

if I try import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';

So now I am using

react: '15.3.0'
react-dom : '15.2.1

XidongHuang avatar May 10 '17 12:05 XidongHuang

I use

    "react": "15.4.2",
    "react-addons-update": "15.4.2",
    "react-bootstrap": "0.31.0",
    "react-bootstrap-table": "3.3.0",
    "react-datetime": "2.8.10",
    "react-dnd": "2.2.4",
    "react-dnd-html5-backend": "2.2.4",
    "react-dom": "15.4.2",
    "react-flexbox-grid": "1.0.2",
    "react-immutable-proptypes": "2.1.0",
    "react-interpolate-component": "0.10.0",
    "react-loader-advanced": "1.4.1",
    "react-notification-system": "0.2.13",
    "react-overlays": "0.7.0",
    "react-redux": "5.0.3",
    "react-router": "2.8.1",
    "react-router-bootstrap": "0.23.1",
    "react-router-redux": "4.0.8",
    "react-scroll": "1.4.7",
    "react-select": "1.0.0-rc.3",
    "react-textarea-autosize": "4.3.0",
    "react-translate-component": "0.13.2",
    "redux": "3.6.0",
    "redux-api-middleware": "1.0.3",
    "redux-thunk": "2.2.0"

stephanebarbey avatar May 10 '17 14:05 stephanebarbey

ok, seems like i use the same version with you guy but it still work for me ;P Anyway, thanks your solution, if there's still have the same issue, I'll mention this solution, thanks a lots

AllenFang avatar May 11 '17 12:05 AllenFang

I confirm the above solution. I have the same issue and when adding add {...props} in the button <SizePerPageDropDown ... />. it was solved :)

wassimz avatar May 22 '17 07:05 wassimz

That solution works, but produces the following warning for me: Failed prop type: Invalid prop `currSizePerPage` of type `number` supplied to `SizePerPageDropDown`, expected `string`. So I used the following workaround:

sizePerPageDropDown: props => <SizePerPageDropDown variation='dropup'
                                                         {...props}
                                                         currSizePerPage={ '' + props.currSizePerPage } />

So, @AllenFang, why currSizePerPage is a string here: https://github.com/AllenFang/react-bootstrap-table/blob/22727e29d288a8efabc1700063de19ddc92990fe/src/pagination/SizePerPageDropDown.js#L46 shouldn't it be a number instead?

btw thx for the awesome library)

alekseyl1992 avatar May 27 '17 15:05 alekseyl1992

@alekseyl1992, I think is a little bug that I forgot to convert to String for customization for sizePerPageDropDown, I'll fix it soon

AllenFang avatar May 29 '17 14:05 AllenFang

@alekseyl1992, fixed on newest version.

AllenFang avatar Jun 02 '17 14:06 AllenFang

Yes, I confirm - it's fixed. thanks!

alekseyl1992 avatar Jun 07 '17 11:06 alekseyl1992

Hey @AllenFang How do you user onCellEdit with dropdowns? I am trying to save the table the moment the dropdown is updated

EkhatorOwen avatar Jun 23 '18 23:06 EkhatorOwen

Also, How do I increase the cell size?

EkhatorOwen avatar Jun 24 '18 00:06 EkhatorOwen