Code Monkey home page Code Monkey logo

Comments (7)

staminaloops avatar staminaloops commented on August 28, 2024

Hello, this was happening to us too. We find out that if you click on the radio/checkbox with clickToSelect set to true, it will call onRowSelect twice (one for the radio/checkbox and one for the row); if you just click on the row, onRowSelect will be called only once.

from react-bootstrap-table.

TonyVeigel avatar TonyVeigel commented on August 28, 2024

I just tried your scenario and if I click on the checkbox I now get four times the data, if I click on the row I get two times the data.

from react-bootstrap-table.

AllenFang avatar AllenFang commented on August 28, 2024

I'll fix this problem quickly :)

from react-bootstrap-table.

AllenFang avatar AllenFang commented on August 28, 2024

I've solved this problem in newest version(v0.9.13)

from react-bootstrap-table.

TonyVeigel avatar TonyVeigel commented on August 28, 2024

This fixes the second part of the issue, but not the first. I have an example below modified from your demo.js. Console will show the duplicates.

import React from 'react';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';

var products = [];
var selectedRows = [];
function addProducts(quantity) {
  var startId = products.length;
  for (var i = 0; i < quantity; i++) {
    var id = startId + i;
    products.push({
      id: id,
      name: "Item name " + id,
      price: 100 + i
    });
  }
}

addProducts(70);

function onRowSelect(row, isSelected){
  selectedRows.push(row.id);
  console.log(selectedRows);
  console.log("selected: " + isSelected)
}

function onSelectAll(isSelected){
  console.log("is select all: " + isSelected);
}

function onAfterSaveCell(row, cellName, cellValue){
  console.log("Save cell '"+cellName+"' with value '"+cellValue+"'");
  console.log("Thw whole row :");
  console.log(row);
}

function onAfterTableComplete(){
  console.log('Table render complete.');
}

var selectRowProp = {
  mode: "checkbox",
  clickToSelect: true,
  selected: selectedRows, //default select on table
  bgColor: "rgb(238, 193, 213)",
  onSelect: onRowSelect
};

var cellEditProp = {
  mode: "click",
  blurToSave: true,
  afterSaveCell: onAfterSaveCell
};

var options = {
  sortName: "name",  //default sort column name
  sortOrder: "desc",  //default sort order
  afterTableComplete: onAfterTableComplete // A hook for after table render complete.
};


function priceFormatter(cell, row){
  return '<i class="glyphicon glyphicon-usd"></i> ' + cell;
}

React.render(
  <BootstrapTable data={products} striped={true} hover={true} pagination={true} selectRow={selectRowProp} cellEdit={cellEditProp}
                  insertRow={true} deleteRow={true} search={true} columnFilter={true} options={options}>
      <TableHeaderColumn dataField="id" dataAlign="center" dataSort={true} isKey={true}>Product ID</TableHeaderColumn>
      <TableHeaderColumn dataField="name" dataSort={true}>Product Name</TableHeaderColumn>
      <TableHeaderColumn dataField="price" dataFormat={priceFormatter} editable={false}>Product Price</TableHeaderColumn>
  </BootstrapTable>,
    document.getElementById("basic")
);

from react-bootstrap-table.

AllenFang avatar AllenFang commented on August 28, 2024

Hi @TonyVeigel, I'll check it, thanks very much.

from react-bootstrap-table.

AllenFang avatar AllenFang commented on August 28, 2024

HI @TonyVeigel, I think the bug has been resolved. your question is you push the on selected row data to selectedRows, but also assign selectedRows to default select. so I recommand you assign another one variable to store the row which on select.

from react-bootstrap-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.