Comments (8)
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.
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.
One more question, is there a way to batch delete?
from jsgrid.
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.
Fixed
from jsgrid.
@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.
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.
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.
@wonsuc, glad that you figured it out.
from jsgrid.
Related Issues (20)
- Trying to use edit template to create a blank text box. HOT 1
- JsGrid with fully working multiselect
- MyDateField issue
- text not showing foe select field after insert data and edit data in jsGrid
- Vertical Scroll Bar Hiding Controls Column HOT 3
- event on cell value change HOT 1
- Can't customize the control button
- Feature Request / Help - Want to set default filtering options
- Changing pageSize reloads the data in grid.
- How to implement Hierarchical Grid on n level.
- Difference between itemTemplate and cellRendering
- How to add subgrid in parent grid HOT 1
- Js grid get cell value cellClick HOT 2
- Need help datetime-local HOT 1
- Is there an official fork that is being heavily used and actively maintained? HOT 1
- Jsgrid select with search box HOT 1
- Detect value of selected value when inserting a new item
- 数据操作时,有没有直接失去焦点保存数据?
- JS grid load data above 5000
- editTemplate on row change error throw $inputFrom was not an function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsgrid.