Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When will the add a row and delete a row functionality be implemented #544

Open
jbp17 opened this issue Sep 13, 2018 · 14 comments
Open

When will the add a row and delete a row functionality be implemented #544

jbp17 opened this issue Sep 13, 2018 · 14 comments

Comments

@jbp17
Copy link

jbp17 commented Sep 13, 2018

I really like your grid. It looks nice and easy to use and customize. Nice job! But it is missing the functionalities of adding and deleting a row and I can't use it unless these functionality is available. What is your timeline for getting it implemented?

@jbp17 jbp17 changed the title When will the add a row and delete a row functionality will be implemented When will the add a row and delete a row functionality be implemented Sep 13, 2018
@AllenFang
Copy link
Member

hello @jbp17 currently, after the react-bootstrap-table2-tookkit supported, I think we will have add/delete row soon. But I can not tell you the timing due to sometime I am busy. but I will implement it ASAP. thank 👍

@jbp17
Copy link
Author

jbp17 commented Sep 17, 2018

Thank you!

@waynebrantley
Copy link

@jbp17 We implemented them ourselves in the grid, using column formatter to conditionally display an edit field, etc. Works nicely.

@alyssa1995
Copy link

@waynebrantley can you show how you added a delete and add button to add/delete rows?

@waynebrantley
Copy link

Here is an example delete button. This is the column definition for the delete column.

        {
            dataField: "databasePkey",
            text: "Remove",
            formatter: (cellContent: string, row: IMyColumnDefinition) => {
                if (row.canRemove)
                    return <button className="btn btn-danger btn-xs" onClick={() => this.handleDelete(row.databasePkey)}>Delete</button>
                return null
            },
        },

The handler for handleDelete does an api call to backend to delete row...that call is a promise and after it completes it makes an api call to backend to get new grid data. It of course could have just removed it directly from the grid state or whatever.

@AllenFang AllenFang added this to To do in release-2019-q1-4 via automation Feb 10, 2019
@prateek04
Copy link

what is string and IMyColumnDefinition and row.databasePkey here.
{
dataField: "databasePkey",
text: "Remove",
formatter: (cellContent: string, row: IMyColumnDefinition) => {
if (row.canRemove)
return <button className="btn btn-danger btn-xs" onClick={() => this.handleDelete(row.databasePkey)}>Delete
return null
},
},

@jbp17
Copy link
Author

jbp17 commented May 16, 2019

@waynebrantley Thank you for sharing your solution. What I actually mean to say is when will the functionality of updating the entire row be added. Right now, the user can click or double-click any cell and modify the content of it. It is a very nice and convenient feature. But it might cause accidentally change of the data very easily. Some end-user might not like that. They might prefer to an update button at the beginning or end of the row. When clicking on the button, the row changes to an update state. The user can update any cell in the same row. When he/she is satisfied with the change, it will click the Save button. The row will return to a state that is not editable.

@thanateros
Copy link

I was so excited to use this library then ran into the same issue: if it can't edit a row at once and insert and delete then it has become useless to me. I agree with @waynebrantley .

@waynebrantley
Copy link

@jbp17 Yes, we do the same thing - we have an edit button on the row, and we create a form outside the grid....which is great because rarely is it 'simple' enough to edit in the grid directly..

@thanateros
Copy link

@waynebrantley I think your advice just saved my day.

@dailymp
Copy link

dailymp commented Sep 6, 2019

@waynebrantley and @AllenFang I have a problem when deleting the last element in a page.
The paginator breaks down because is not taking into account the change, this page should dissapear due to lacks of elements in it, but instead it throws an error:
image
Please could you help me?

@maakle
Copy link

maakle commented May 5, 2020

Credits to @waynebrantley . I simplified it for others who need it in Javascript and more verbose example. The example assumes, that your objects have a property called id that identifies the object.

const dealColumns = [
  {
    dataField: "firstname",
    text: "First Name",
  },
// all your columns and data
  {
    dataField: "id",
    text: "Remove",
    editable: false,
    formatter: (cellContent, row) => {
      return (
        <button
          className="btn btn-danger btn-xs"
          onClick={() => handleDelete(row.id)}
        >
          Delete
        </button>
      );
    },
  },
];

const handleDelete = (rowId) => {
  console.log(rowId);
};

@peterkronenberg
Copy link

I'm just getting started with using this package. Adding and deleting rows is definitely something I need. Has this been officially implemented?

@Fashad-Ahmed
Copy link

Fashad-Ahmed commented Jan 15, 2022

@peterkronenberg you can refer @mathiasklenk for deleting rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

10 participants