Git Product home page Git Product logo

Comments (8)

tabalinas avatar tabalinas commented on July 2, 2024

Hi,

Thank you!
According to docs for deleteItem, it accepts item|$row|rowNode is the reference to the item or the row jQueryElement or the row DomNode. Since js literal object {} is a new object, so the item just cannot be found in the grid data.

To make it work you can use a reference to item:

$(element).jsGrid("deleteItem", data[0]); // delete first item

Docs link: http://js-grid.com/docs/#deleteitemitemrowrownode-promise

from jsgrid.

jonavila avatar jonavila commented on July 2, 2024

Tabalinas, I figured out the problem. I was using the data option and not the controller option to load my data. As soon as I changed it to use loadData function, everything worked.

Thanks

from jsgrid.

jonavila avatar jonavila commented on July 2, 2024

One more question, is there a way to batch delete?

from jsgrid.

tabalinas avatar tabalinas commented on July 2, 2024

If you mean batch delete with UI, it can be done with custom field to select several items.
See following fiddle http://jsfiddle.net/tabalinas/40atrzbo/
Hope it's what you mentioned.

from jsgrid.

tabalinas avatar tabalinas commented on July 2, 2024

Fixed

from jsgrid.

wonsuc avatar wonsuc commented on July 2, 2024

@tabalinas I need a help.
I'm trying to implement batch delete with UI based on your fiddle source code.
Here's my fiddle => http://jsfiddle.net/40atrzbo/78/

And I get this error on my console.
2018-02-08 4 09 44

I needed callback listener when all file deleted. So I added callback function when file deleted as below.

$("#jsgrid").jsGrid("deleteItem", item).done(function() {
    console.log("Delete completed.");
});

It works well, but if the jsGrid instance has pages, the error keep occurring at the every last child of all pages except first page, and it only happens if you selected multiple rows, but a single row.
And the last child row won't be deleted.
It seems it's a bug. Is there any solution for it?

I will be thankful with any comment!

from jsgrid.

wonsuc avatar wonsuc commented on July 2, 2024

Sorry I fixed by myself.
It is happening because of loadStrategy and every time when I delete some row the page is go back first page, so when the code try to delete second row, the row is not exists at current view anymore.
This answer helped me a lot => #43

jsGrid.loadStrategies.DirectLoadingStrategy.prototype.finishDelete = function(deletedItem, deletedItemIndex) {
    var grid = this._grid;
    grid.option("data").splice(deletedItemIndex, 1);
    grid.refresh();
    if (grid.option("data").length == 0) {
        grid.reset();
    } else if (grid._content[0].children.length == 0) {
        var targetPageIndex = grid.pageIndex == 1 ? 1 : grid.pageIndex - 1;
        grid.openPage(targetPageIndex);
    }
}

from jsgrid.

tabalinas avatar tabalinas commented on July 2, 2024

@wonsuc, glad that you figured it out.

from jsgrid.

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.