Grillos / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

Enchancement: implement delete functionality for multiple rows #53

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
would be nice to have delete functionality for more than one row

Original issue reported on code.google.com by DevassyT...@gmail.com on 6 Aug 2011 at 5:58

GoogleCodeExporter commented 8 years ago
I will consider this for the next version.

Original comment by joc...@gmail.com on 19 Aug 2011 at 10:32

GoogleCodeExporter commented 8 years ago
Thank you.Hope to see this in next version soon

Original comment by DevassyT...@gmail.com on 21 Aug 2011 at 4:08

GoogleCodeExporter commented 8 years ago
any news here?

Original comment by jurijs.k...@gmail.com on 26 Mar 2012 at 1:57

GoogleCodeExporter commented 8 years ago
Solved.
Add inside jquery.dataTables.editable.js :
[code]
function fnGetSelected( oTableLocal )
        {
            var aReturn = new Array();
            var aTrs = oTableLocal.fnGetNodes();

            for ( var i=0 ; i<aTrs.length ; i++ )
            {
                if ( $(aTrs[i]).hasClass('DTTT_selected') )
                {
                    aReturn.push( aTrs[i] );
                }
            }
            return aReturn;
        }       
[/code]

Your  _fnOnRowDelete should be like this:
[code]
function _fnOnRowDelete(event) {
            iDisplayStart = _fnGetDisplayStart();
            if ($('tr.' + properties.sSelectedRowClass + ' td', oTable).length == 0) {
                oDeleteRowButton.attr("disabled", "true");
                _fnDisableDeleteButton();
                return;
            }

            var anSelected = fnGetSelected( oTable );           

            for (var n=0; n<anSelected.length; n++) {
                //oTable.fnDeleteRow( anSelected[n], null, true );
                _fnDeleteRow( anSelected[n].id );
                oTable.fnDeleteRow( anSelected[n], null, true );
            }

        }
[/code]

And also  comment some lines _fnOnRowDeleted :
[code]
function _fnOnRowDeleted(response) {
            properties.fnEndProcessingMode();
            //oTRSelected = $('tr.' + properties.sSelectedRowClass, oTable);

            if (response == "ok" || response == "") {
                //oTable.fnDeleteRow(oTRSelected[0]);
                //oDeleteRowButton.attr("disabled", "true");
                _fnDisableDeleteButton();
                _fnSetDisplayStart();
                properties.fnOnDeleted("success");
            }
            else {
                properties.fnShowError(response, "delete");
                properties.fnOnDeleted("failure");
            }
        }
[/code]

Original comment by jurijs.k...@gmail.com on 27 Mar 2012 at 7:37