Hi Team,
I have an iggrid where I am doing insert, update and delete operations . On click of add new row ,data will get saved to the grid, not to the database and on click of delete icon, records should get deleted from the UI, not from the database and it is working .
My requirement is below :
I need delete icon only on last row while binding the data from the database
I need delete icon only on last row while adding data dynamically only in UI (not in db) .
Hello Tapas,
After investigating this further, I determined that we do not provide a functionality to render delete icon only for the last row out of the box. What I can suggest is logging a new product idea on our ideas site. This will give you the opportunity to communicate directly with our developers.
What I can suggest as an alternative is modifying the default logic that shows the delete button in igGrid. Please keep in mind that in case that this approach is applied this would affect all igGrids in your application. There is a showDeleteButtonFor method in the igGridUpdating feature that determines when this button to be displayed. By design, this button is shown for every row. This is controlled with a simple if clause shown below:
$.ui.igGridUpdating.prototype.showDeleteButtonFor = function (row) { var db = $("#" + this.grid.id() + "_updating_deletehover"), ……………………; if (db.length) { db.show(); ………. }
If this logic is modified in order to check not only whether there is a delete button but to check whether the row that triggered the event is the last row in the data source. I believe this will help you achieve your requirement.
$.ui.igGridUpdating.prototype.showDeleteButtonFor = function (row) { var db = $("#" + this.grid.id() + "_updating_deletehover"), ……………………; if (db.length && $(row[0]).attr("data-id") === this.grid.dataSource.data()[this.grid.dataSource.data().length - 1].yourPrimaryKey) { db.show(); ………. }
I am attaching a sample demonstrating how this could be done. Please keep in mind that this is a workaround and may cause unexpected behavior. Please carefully test all aspects of your application before implementing the suggested approach.
Please let me know if you need any further assistance with this matter.
Looking forward to hearing from you.
Regards,
Monika Kirkova,
Infragistics
igGridDeleteButtonForLastRow.zip
Thanks Monika, it worked .
As we have only one grid on that page so it worked and didnt affect any other grid .
I do have one more thing , as of now delete button is coming onhover of last row. Can I get it displayed directly on last row. It should not appear only on hover .how can we display delete as a static button on last row only