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

Get Row By Index

Open noisypebble opened this issue 2 years ago • 1 comments

Description

Team,

Is there a way to get a row by index in addition to the unique id?

$table.bootstrapTable('getRowByUniqueId', 1) works great, but I'm attempting to modify the CRUD table example to add a Next and Previous button to the modal. Since the unique id may not be sequential I need a way to do the same thing with the index. I thought about using the scrollTo method and then just getting the row at index 0 but I'm not sure that will work or is the best. Any suggestions?

Thank you for this excellent project. If I can get my use case working it will save me weeks of development.

Example(s)

No response

noisypebble avatar Jan 19 '23 16:01 noisypebble

You can use getData and then do whatever you want with it. Example:

<script>
  const $table = $('#table')
  const $button = $('#button')
  $(function() {
    $button.click(function () {
      var data = $table.bootstrapTable('getData');
      var currentIndex = data.findIndex(x => x.id == 1);
      var nextRow = data[currentIndex + 1]
      alert(JSON.stringify(nextRow))  
    })    
  })
</script>

rogeriolaa avatar Jul 28 '25 11:07 rogeriolaa